Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Benchmark = require('benchmark');
- var suite = new Benchmark.Suite;
- suite.add('indexOf', function() {
- var s = "time:2017-01-01T11:22:33Z"
- var i = s.indexOf(":")
- return [ s.slice(0,i), s.slice(i+1) ];
- })
- .add("replace\\0", function() {
- var s = "time:2017-01-01T11:22:33Z"
- return s.replace(":", "\0").split("\0");
- })
- .add("regexp", function() {
- var s = "time:2017-01-01T11:22:33Z"
- var m = s.match(/^(.*?):(.*)$/);
- return [ m[1], m[2] ];
- })
- .on('cycle', function(event) {
- console.log(String(event.target));
- })
- .on('complete', function() {
- console.log('Fastest is ' + this.filter('fastest').map('name'));
- })
- // run async
- .run({ 'async': true });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement