1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <!-- Copyright 2008 Google Inc. All rights reserved. -->
6 <title> Simple RPC Performance Tests
</title>
7 <script type=
"application/x-javascript">
9 var ClearCanvas = function() {
10 this.context.fillStyle = 'rgb(0,0,0)';
11 this.context.fillRect(0, 0, this.xsize, this.ysize);
12 this.output.textContent = this.type;
15 var BenchSteps = 50000;
16 var RunBenchmark = function() {
17 var context = this.context;
18 var steps = BenchSteps;
19 var point_function = this.point_function;
20 var output = document.getElementById('LogOutput'); // this.output;
23 for (var i = 0; i < steps; i++) {
24 var before_call = new Date();
25 var arr = point_function();
26 var after_call = new Date();
27 var difftime = after_call.getTime() - before_call.getTime();
28 call_time = call_time + difftime;
29 if (difftime > worst_time) {
33 output.innerHTML += this.type + ": " + call_time + ' ms (' + (call_time / steps) + ' per call; worst ' + worst_time + ')<BR>\n';
36 var Benchmark = function(type, point_function) {
38 this.point_function = point_function;
39 this.output = document.getElementById(type + 'Output');
40 this.Run = RunBenchmark;
45 var BenchBigStringTest;
47 var BenchNullNpapiTest;
50 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
51 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
52 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
53 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
54 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
55 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
56 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
57 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
58 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
59 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
60 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
61 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
62 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
63 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
64 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +
65 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
67 // Init is called when the document has completed loading. It downloads the
68 // NativeClient module and sets up the two benchmark run methods.
69 var Init = function(boxsize) {
70 var log = document.getElementById('LogOutput');
71 // Remember the element for the Native Client service.
72 native_client_service = document.getElementById('nacl');
73 // Set a banner in the log.
74 log.innerHTML += "Using " + BenchSteps + " iterations for each test<BR>\n";
75 // Create a NativeClient version of the benchmark.
76 var IntTestNativeClient = function() {
77 return native_client_service.int(0);
79 BenchIntTest = new Benchmark('IntTest', IntTestNativeClient);
80 var StringTestNativeClient = function() {
81 return native_client_service.string("hello world");
83 BenchStringTest = new Benchmark('StringTest', StringTestNativeClient);
84 var BigStringTestNativeClient = function() {
85 return native_client_service.string(OneKString);
88 new Benchmark('BigStringTest', BigStringTestNativeClient);
89 var NullRpcTestNativeClient = function() {
90 return native_client_service.string(OneKString);
92 BenchNullTest = new Benchmark('NullRpcTest', NullRpcTestNativeClient);
93 var NullNpapiTestNativeClient = function() {
94 return native_client_service.__nullNpapiMethod(OneKString);
97 new Benchmark('NullNpapiTest', NullNpapiTestNativeClient);
102 <body onload=
"Init();">
103 <h1> Native Client Simple RPC Performance Tests
</h1>
104 <table summary=
"A collection of buttons to invoke tests">
108 <input type=
"button" onclick=
"BenchIntTest.Run()"
112 <input type=
"button" onclick=
"BenchStringTest.Run()"
113 value=
"StringTest" />
116 <input type=
"button" onclick=
"BenchBigStringTest.Run()"
117 value=
"BigStringTest">
121 <input type=
"button" onclick=
"BenchNullTest.Run()"
122 value=
"NullRpcTest" />
125 <input type=
"button" onclick=
"BenchNullNpapiTest.Run()"
126 value=
"NullNpapiTest" />
131 Click any button above to run a benchmark.
133 <embed type=
"application/x-nacl-srpc" id=
"nacl" height=
"0" width=
"0"
134 src=
"srpc_test.nexe" />
135 <table summary=
"A box containing execution logging output">
137 <td id=
"LogOutput" />