| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
| 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
| 3 <html> | |
| 4 <!-- Copyright 2008 Google Inc. All rights reserved. --> | |
| 5 <head> | |
| 6 <title> Simple RPC Performance Tests </title> | |
| 7 <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> | |
| 8 <META HTTP-EQUIV="Expires" CONTENT="-1"> | |
| 9 <script type="application/x-javascript"> | |
| 10 //<![CDATA[ | |
| 11 var ClearCanvas = function() { | |
| 12 this.context.fillStyle = 'rgb(0,0,0)'; | |
| 13 this.context.fillRect(0, 0, this.xsize, this.ysize); | |
| 14 this.output.textContent = this.type; | |
| 15 } | |
| 16 | |
| 17 var BenchSteps = 50000; | |
| 18 var RunBenchmark = function() { | |
| 19 var context = this.context; | |
| 20 var steps = BenchSteps; | |
| 21 var point_function = this.point_function; | |
| 22 var output = document.getElementById('LogOutput'); // this.output; | |
| 23 var call_time = 0; | |
| 24 var worst_time = 0; | |
| 25 for (var i = 0; i < steps; i++) { | |
| 26 var before_call = new Date(); | |
| 27 var arr = point_function(); | |
| 28 var after_call = new Date(); | |
| 29 var difftime = after_call.getTime() - before_call.getTime(); | |
| 30 call_time = call_time + difftime; | |
| 31 if (difftime > worst_time) { | |
| 32 worst_time = difftime | |
| 33 } | |
| 34 } | |
| 35 output.innerHTML += | |
| 36 this.type + ': ' + call_time + ' ms (' + (call_time / steps) + | |
| 37 ' per call; worst ' + worst_time + ')<BR>\n'; | |
| 38 } | |
| 39 | |
| 40 var Benchmark = function(type, point_function) { | |
| 41 this.type = type; | |
| 42 this.point_function = point_function; | |
| 43 this.output = document.getElementById(type + 'Output'); | |
| 44 this.Run = RunBenchmark; | |
| 45 } | |
| 46 | |
| 47 var BenchIntTest; | |
| 48 var BenchStringTest; | |
| 49 var BenchBigStringTest; | |
| 50 var BenchNullTest; | |
| 51 var BenchNullNpapiTest; | |
| 52 var BenchRPC3x; | |
| 53 var OneKString = | |
| 54 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 55 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 56 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 57 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 58 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 59 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 60 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 61 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 62 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 63 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 64 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 65 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 66 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 67 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 68 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + | |
| 69 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; | |
| 70 | |
| 71 // Init is called when the document has completed loading. It downloads the | |
| 72 // NativeClient module and sets up the two benchmark run methods. | |
| 73 var Init = function(boxsize) { | |
| 74 var log = document.getElementById('LogOutput'); | |
| 75 // Remember the element for the Native Client service. | |
| 76 native_client_service = document.getElementById('nacl'); | |
| 77 // Set a banner in the log. | |
| 78 log.innerHTML += "Using " + BenchSteps + " iterations for each test<BR>\n"; | |
| 79 // Create a NativeClient version of the benchmark. | |
| 80 var IntTestNativeClient = function() { | |
| 81 return native_client_service.int(0); | |
| 82 } | |
| 83 BenchIntTest = new Benchmark('IntTest', IntTestNativeClient); | |
| 84 var StringTestNativeClient = function() { | |
| 85 return native_client_service.string("hello world"); | |
| 86 } | |
| 87 BenchStringTest = new Benchmark('StringTest', StringTestNativeClient); | |
| 88 var BigStringTestNativeClient = function() { | |
| 89 return native_client_service.string(OneKString); | |
| 90 } | |
| 91 BenchBigStringTest = | |
| 92 new Benchmark('BigStringTest', BigStringTestNativeClient); | |
| 93 var NullRpcTestNativeClient = function() { | |
| 94 return native_client_service.string(OneKString); | |
| 95 } | |
| 96 BenchNullTest = new Benchmark('NullRpcTest', NullRpcTestNativeClient); | |
| 97 var NullNpapiTestNativeClient = function() { | |
| 98 return native_client_service.__nullPluginMethod(OneKString); | |
| 99 } | |
| 100 BenchNullNpapiTest = | |
| 101 new Benchmark('NullNpapiTest', NullNpapiTestNativeClient); | |
| 102 } | |
| 103 //]]> | |
| 104 </script> | |
| 105 </head> | |
| 106 <body onload="Init();"> | |
| 107 <h1> Native Client Simple RPC Performance Tests </h1> | |
| 108 <table summary="A collection of buttons to invoke tests"> | |
| 109 <thead> | |
| 110 <tr> | |
| 111 <td align=center> | |
| 112 <input type="button" onclick="BenchIntTest.Run()" | |
| 113 value="IntTest" /> | |
| 114 </td> | |
| 115 <td align=center> | |
| 116 <input type="button" onclick="BenchStringTest.Run()" | |
| 117 value="StringTest" /> | |
| 118 </td> | |
| 119 <td align=center> | |
| 120 <input type="button" onclick="BenchBigStringTest.Run()" | |
| 121 value="BigStringTest"> | |
| 122 </input> | |
| 123 </td> | |
| 124 <td align=center> | |
| 125 <input type="button" onclick="BenchNullTest.Run()" | |
| 126 value="NullRpcTest" /> | |
| 127 </td> | |
| 128 <td align=center> | |
| 129 <input type="button" onclick="BenchNullNpapiTest.Run()" | |
| 130 value="NullNpapiTest" /> | |
| 131 </td> | |
| 132 </thead> | |
| 133 </table> | |
| 134 <h2> | |
| 135 Click any button above to run a benchmark. | |
| 136 </h2> | |
| 137 <embed type="application/x-ppapi-nacl-srpc" id="nacl" height="0" width="0" | |
| 138 src="srpc_test.nexe" /> | |
| 139 <table summary="A box containing execution logging output"> | |
| 140 <tr> | |
| 141 <td id="LogOutput" /> | |
| 142 </tr> | |
| 143 </table> | |
| 144 </body> | |
| 145 </html> | |
| OLD | NEW |