Last active
March 28, 2016 17:13
-
-
Save colwem/035a797672a0e4269463 to your computer and use it in GitHub Desktop.
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
| eq | |
| [ { total_runtime: 368, | |
| total_step_runtime: 25, | |
| average_step_runtime: 0.00025 }, | |
| { total_runtime: 477, | |
| total_step_runtime: 57, | |
| average_step_runtime: 0.00057, | |
| total_off_baseline: 106, | |
| total_step_off_baseline: 25, | |
| average_step_off_baseline: 0.00024999999999999995 } ] | |
| reMatch | |
| [ { total_runtime: 371, | |
| total_step_runtime: 32, | |
| average_step_runtime: 0.00032 }, | |
| { total_runtime: 479, | |
| total_step_runtime: 101, | |
| average_step_runtime: 0.00101, | |
| total_off_baseline: 108, | |
| total_step_off_baseline: 69, | |
| average_step_off_baseline: 0.0006900000000000001 } ] |
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
| var timeit = require('timeit'); | |
| var times = 100000; | |
| function eq(str, done) { | |
| if(str === str){ | |
| i++; | |
| }; | |
| done(); | |
| } | |
| function reMatch(regex, str, done) { | |
| if(regex.test(str)) { | |
| i++; | |
| }; | |
| done(); | |
| } | |
| var regex = /abcdefghijklmnop/; | |
| var str = 'abcdefghijklmnop'; | |
| var i = 0; | |
| timeit.howlong(times, eq.bind(eq, str), function(err, data) { | |
| console.log('eq'); | |
| console.log(data); | |
| }); | |
| timeit.howlong(times, reMatch.bind(reMatch, regex, str), function(err, data) { | |
| console.log("reMatch"); | |
| console.log(data); | |
| }); | |
| console.log("done"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment