~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/js/src/xpconnect/tests/js/old/speed.js

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
print(".......................................");
 
2
print("simple speed tests...");
 
3
 
 
4
var iterations = 1000;
 
5
 
 
6
var receiver2 = new Object();
 
7
receiver2.SetReceiver = function() {};
 
8
receiver2.SendOneString = function(str) {/*print(str);*/};
 
9
 
 
10
var echoJS = new Object();
 
11
echoJS.SetReceiver = function(r) {this.r = r;};
 
12
echoJS.SendOneString = function(str) {if(this.r)this.r.SendOneString(str)};
 
13
echoJS.SimpleCallNoEcho = function(){}
 
14
 
 
15
/*********************************************/
 
16
/*********************************************/
 
17
 
 
18
print("\nEcho.SimpleCallNoEcho (just makes call with no params and no callback)");
 
19
var start_time = new Date().getTime()/1000;
 
20
echoJS.SetReceiver(receiver2);
 
21
for(i = 0; i < iterations; i++)
 
22
    echoJS.SimpleCallNoEcho();
 
23
var end_time = new Date().getTime()/1000;
 
24
var interval = parseInt(100*(end_time - start_time),10)/100;
 
25
print("JS control did "+iterations+" iterations in "+interval+ " seconds.");
 
26
 
 
27
/*
 
28
var start_time = new Date().getTime()/1000;
 
29
echo.SetReceiver(receiver2);
 
30
for(i = 0; i < iterations; i++)
 
31
    echo.SimpleCallNoEcho();
 
32
var end_time = new Date().getTime()/1000;
 
33
var interval = parseInt(100*(end_time - start_time),10)/100;
 
34
print("XPConnect  did "+iterations+" iterations in "+interval+ " seconds.");
 
35
*/
 
36
 
 
37
/*********************************************/
 
38
 
 
39
print("\nEcho.SendOneString (calls a callback that does a call)");
 
40
var start_time = new Date().getTime()/1000;
 
41
echoJS.SetReceiver(receiver2);
 
42
for(i = 0; i < iterations; i++)
 
43
    echoJS.SendOneString("foo");
 
44
var end_time = new Date().getTime()/1000;
 
45
var interval = parseInt(100*(end_time - start_time),10)/100;
 
46
print("JS control did "+iterations+" iterations in "+interval+ " seconds.");
 
47
 
 
48
/*
 
49
var start_time = new Date().getTime()/1000;
 
50
echo.SetReceiver(receiver2);
 
51
for(i = 0; i < iterations; i++)
 
52
    echo.SendOneString("foo");
 
53
var end_time = new Date().getTime()/1000;
 
54
var interval = parseInt(100*(end_time - start_time),10)/100;
 
55
print("XPConnect  did "+iterations+" iterations in "+interval+ " seconds.");
 
56
*/
 
57
 
 
58
print(".......................................");
 
59
 
 
60
echoJS.SetReceiver(null);