Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. var Benchmark = require('benchmark');
  2. var suite = new Benchmark.Suite;
  3. suite.add('indexOf', function() {
  4. var s = "time:2017-01-01T11:22:33Z"
  5. var i = s.indexOf(":")
  6. return [ s.slice(0,i), s.slice(i+1) ];
  7. })
  8. .add("replace\\0", function() {
  9. var s = "time:2017-01-01T11:22:33Z"
  10. return s.replace(":", "\0").split("\0");
  11. })
  12. .add("regexp", function() {
  13. var s = "time:2017-01-01T11:22:33Z"
  14. var m = s.match(/^(.*?):(.*)$/);
  15. return [ m[1], m[2] ];
  16. })
  17. .on('cycle', function(event) {
  18. console.log(String(event.target));
  19. })
  20. .on('complete', function() {
  21. console.log('Fastest is ' + this.filter('fastest').map('name'));
  22. })
  23. // run async
  24. .run({ 'async': true });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement