Skip to content

Instantly share code, notes, and snippets.

@colwem
Last active March 28, 2016 17:13
Show Gist options
  • Select an option

  • Save colwem/035a797672a0e4269463 to your computer and use it in GitHub Desktop.

Select an option

Save colwem/035a797672a0e4269463 to your computer and use it in GitHub Desktop.
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 } ]
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