Guest User

Untitled

a guest
Aug 9th, 2016
53
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Benchmark = require('benchmark');
  2.  
  3. var suite = new Benchmark.Suite;
  4.  
  5. var x = " ";
  6. var text = "             a                      b                     ";
  7. var pat = /.*a.*?b./;
  8.  
  9. suite
  10. .add('RegExp#exec', function() {
  11.   return pat.exec( text + x );
  12. })
  13. .add('RegExp#group()', function() {
  14.   return pat.exec( text + x )[0];
  15. })
  16. .add('RegExp#groupCount()', function() {
  17.   return pat.exec( text + x ).length - 1;
  18. })
  19. .add('RegExp#exec_const', function() {
  20.   return pat.exec( text );
  21. })
  22. .on('cycle', function(event) {
  23.   console.log(String(event.target));
  24. })
  25. // run async
  26. .run({ 'async': true });
RAW Paste Data