Skip to content
Browse files

Adding benchmarkjs and a folder that will contain our speed tests usi…

…ng it. we need to migrate all our old speed tests to use benchmarkjs
  • Loading branch information...
1 parent 39ceb00 commit 7af5c4b01a78d9c4780f8005deefcf2a61affeb5 @fabiomcosta fabiomcosta committed Feb 20, 2011
Showing with 51 additions and 0 deletions.
  1. +3 −0 .gitmodules
  2. +1 −0 speed/benchmarkjs
  3. +14 −0 speed/speedtests/index.html
  4. +33 −0 speed/speedtests/setdocument.html
View
3 .gitmodules
@@ -1,3 +1,6 @@
[submodule "SlickSpec/Runner"]
path = SlickSpec/Runner
url = git://github.com/mootools/mootools-runner.git
+[submodule "speed/benchmarkjs"]
+ path = speed/benchmarkjs
+ url = https://github.com/mathiasbynens/Benchmark.js.git
1 speed/benchmarkjs
@@ -0,0 +1 @@
+Subproject commit 6468de1128ed93a166f3e1e95c22022415abf839
View
14 speed/speedtests/index.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
+ <title>index</title>
+ </head>
+ <body>
+ <h2>Speed tests</h2>
+ <ul>
+ <li><a href="setdocument.html">setdocument.html</a></li>
+ </ul>
+ </body>
+</html>
View
33 speed/speedtests/setdocument.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
+ <title>setdocument</title>
+ <script type="text/javascript" src="../benchmarkjs/benchmark.js"></script>
+ </head>
+ <body>
+ <applet code="nano" archive="../benchmarkjs/nano.jar"></applet>
+ <script type="text/javascript">
+ var suite = new Benchmark.Suite;
+ // add tests
+ suite.add('RegExp#test', function() {
+ /o/.test('Hello World!');
+ })
+ .add('String#indexOf', function() {
+ 'Hello World!'.indexOf('o') > -1;
+ })
+ .add('String#match', function() {
+ !!'Hello World!'.match(/o/);
+ })
+ // add listeners
+ .on('cycle', function(bench) {
+ console.log(String(bench));
+ })
+ .on('complete', function() {
+ console.log('Fastest is ' + this.filter('fastest').pluck('name'));
+ })
+ .run(true);
+ </script>
+ </body>
+</html>

0 comments on commit 7af5c4b

Please sign in to comment.
Something went wrong with that request. Please try again.