Created
November 11, 2011 14:50
-
-
Save mapserver2007/1358167 to your computer and use it in GitHub Desktop.
test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <meta charset="UTF-8"/> | |
| <script type="text/javascript" src="mix.js"></script> | |
| <script type="text/javascript" src="test.js"></script> | |
| <script type="text/javascript" src="benchmark.js"></script> | |
| </head> | |
| <body onload="start();"> | |
| <h1>result</h1> | |
| <div id="result"></div> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Mixjs.module("Test1", { | |
| name: function () { | |
| var obj = this.mix(Test2); | |
| return obj; | |
| //console.log("test1"); | |
| } | |
| }); | |
| Mixjs.module("Test2", { | |
| //include: Test1, | |
| name: function () { | |
| console.log("test2"); | |
| } | |
| }); | |
| Mixjs.module("Test3", { | |
| //include: Test2, | |
| name: function () { | |
| console.log("test3"); | |
| } | |
| }); | |
| Mixjs.module("Test4", { | |
| //include: Test2, | |
| name: function () { | |
| console.log("test4"); | |
| } | |
| }); | |
| function start() { | |
| var suite = new Benchmark.Suite; | |
| // add tests | |
| suite.add('Test1.mix(Test2)', function() { | |
| var obj = Test1.mix(Test2); | |
| }) | |
| .add('Test1.mix(Test2).mix(Test3).mix(Test4)', function() { | |
| var obj = Test1.mix(Test2).mix(Test3).mix(Test4); | |
| }) | |
| .add('Test1.mix(Test2, Test3, Test4)', function() { | |
| var obj = Test1.mix(Test2, Test3, Test4); | |
| }) | |
| .add('(Test1.mix(Test2)).mix(Test3.mix(Test4))', function() { | |
| var obj = (Test1.mix(Test2)).mix(Test3.mix(Test4)); | |
| }) | |
| .add('include: Test1', function() { | |
| Mixjs.module("Test5", { | |
| include: Test1, | |
| name: function () { | |
| console.log("test5"); | |
| } | |
| }); | |
| }) | |
| .add('include: [Test1, Test2]', function() { | |
| Mixjs.module("Test6", { | |
| include: [Test1, Test2], | |
| name: function () { | |
| console.log("test6"); | |
| } | |
| }); | |
| }) | |
| .add('include: [Test1, Test2, Test3]', function() { | |
| Mixjs.module("Test7", { | |
| include: [Test1, Test2, Test3], | |
| name: function () { | |
| console.log("test7"); | |
| } | |
| }); | |
| }) | |
| // add listeners | |
| .on('cycle', function(event, bench) { | |
| document.getElementById("result").innerHTML += String(bench) + "<br>"; | |
| }) | |
| .on('complete', function() { | |
| document.getElementById("result").innerHTML += 'Fastest is ' + this.filter('fastest').pluck('name') + "<br>"; | |
| }) | |
| // run async | |
| .run({ 'async': true }); | |
| //var obj = Test1.mix(Test1, Test1).mix(Test4); | |
| //console.log(obj); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment