Skip to content

Instantly share code, notes, and snippets.

@pygy
Created February 7, 2017 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pygy/b3077bf79976441b54878a082ed07f5e to your computer and use it in GitHub Desktop.
Save pygy/b3077bf79976441b54878a082ed07f5e to your computer and use it in GitHub Desktop.
<!doctype html>
<title>XRegExp fast-fake-y benchmarks</title>
<table><tr><td>
<div id="log-after">Testing XRegExp 3.1.1-fast-fake-y.<br>Sit back and relax. This might take a while.<br><br>Constructor with short pattern:<br>XRegExp with pattern cache flush x 88,916 ops/sec ±2.24% (82 runs sampled)<br>XRegExp x 834,869 ops/sec ±1.08% (81 runs sampled)<br>XRegExp.cache x 38,821,522 ops/sec ±1.93% (82 runs sampled)<br>RegExp x 5,654,331 ops/sec ±1.68% (81 runs sampled)<br>Fastest is XRegExp.cache<br><br>Constructor with medium pattern:<br>XRegExp with pattern cache flush x 32,278 ops/sec ±1.20% (83 runs sampled)<br>XRegExp x 856,503 ops/sec ±1.48% (79 runs sampled)<br>XRegExp.cache x 38,742,523 ops/sec ±0.66% (82 runs sampled)<br>RegExp x 5,679,163 ops/sec ±2.44% (80 runs sampled)<br>Fastest is XRegExp.cache<br><br>Constructor with long pattern:<br>XRegExp with pattern cache flush x 1,211 ops/sec ±1.01% (80 runs sampled)<br>XRegExp x 484,537 ops/sec ±0.98% (81 runs sampled)<br>XRegExp.cache x 38,776,122 ops/sec ±0.64% (81 runs sampled)<br>RegExp x 1,046,763 ops/sec ±1.46% (84 runs sampled)<br>Fastest is XRegExp.cache<br><br>Constructor with x flag, whitespace, and comments:<br>XRegExp with pattern cache flush x 77,967 ops/sec ±1.05% (84 runs sampled)<br>XRegExp x 436,507 ops/sec ±2.18% (78 runs sampled)<br>XRegExp.cache x 37,747,528 ops/sec ±1.67% (82 runs sampled)<br>Fastest is XRegExp.cache<br><br>exec:<br>Native exec x 80,448 ops/sec ±0.64% (83 runs sampled)<br>Shimmed exec x 78,835 ops/sec ±0.84% (80 runs sampled)<br>XRegExp.exec x 79,084 ops/sec ±1.22% (82 runs sampled)<br>Fastest is Native exec,XRegExp.exec<br><br>exec with 200000 different strings:<br>Native exec x 76,339 ops/sec ±1.51% (80 runs sampled)<br>Shimmed exec x 80,302 ops/sec ±0.69% (81 runs sampled)<br>XRegExp.exec x 79,858 ops/sec ±0.67% (84 runs sampled)<br>Fastest is Shimmed exec,XRegExp.exec<br><br>Sticky exec with 200000 different strings:<br>Native exec x 80,445 ops/sec ±0.66% (84 runs sampled)<br>Shimmed exec x 80,255 ops/sec ±0.77% (82 runs sampled)<br>XRegExp.exec x 1,807,394 ops/sec ±0.83% (83 runs sampled)<br>Fastest is XRegExp.exec<br><br>Iteration with a nonglobal regex:<br>replace with callback x 28,936 ops/sec ±1.18% (79 runs sampled)<br>while/exec x 50,278 ops/sec ±2.67% (80 runs sampled)<br>while/XRegExp.exec x 40,676 ops/sec ±0.96% (83 runs sampled)<br>XRegExp.forEach x 35,703 ops/sec ±2.65% (78 runs sampled)<br>Fastest is while/exec<br><br>Regex object type:<br>RegExp object x 98,977 ops/sec ±0.76% (84 runs sampled)<br>XRegExp object x 97,285 ops/sec ±1.21% (82 runs sampled)<br>Fastest is RegExp object,XRegExp object<br><br>Capturing:<br>Numbered capture x 97,813 ops/sec ±0.74% (85 runs sampled)<br>Named capture (one name) x 95,850 ops/sec ±1.07% (81 runs sampled)<br>Named capture (four names) x 76,876 ops/sec ±0.96% (82 runs sampled)<br>Fastest is Numbered capture<br><br>Unicode letter construction:<br>Incomplete set: /[a-z]/i x 82,931 ops/sec ±1.54% (79 runs sampled)<br>BMP only: /\p{L}/ x 86,744 ops/sec ±2.22% (78 runs sampled)<br>Full Unicode: /\p{L}/A x 76,593 ops/sec ±3.91% (73 runs sampled)<br>Fastest is BMP only: /\p{L}/<br><br>Unicode letter matching:<br>a-z caseless x 210,352 ops/sec ±0.72% (82 runs sampled)<br>\p{L} x 90,013 ops/sec ±1.70% (82 runs sampled)<br>\p{L} astral x 13,980 ops/sec ±1.87% (78 runs sampled)<br>Fastest is a-z caseless<br><br>Unicode word matching:<br>a-z caseless x 84,678 ops/sec ±0.88% (84 runs sampled)<br>\p{L} x 26,579 ops/sec ±0.91% (82 runs sampled)<br>\p{L} astral x 3,170 ops/sec ±0.70% (82 runs sampled)<br>Fastest is a-z caseless<br><br>Finished. ☺</div>
</td><td>
<div id="log">Testing XRegExp 3.1.1-next.<br>Sit back and relax. This might take a while.<br><br>Constructor with short pattern:<br>XRegExp with pattern cache flush x 61,242 ops/sec ±7.22% (58 runs sampled)<br>XRegExp x 363,671 ops/sec ±3.70% (67 runs sampled)<br>XRegExp.cache x 36,638,533 ops/sec ±1.85% (70 runs sampled)<br>RegExp x 1,093,123 ops/sec ±2.45% (74 runs sampled)<br>Fastest is XRegExp.cache<br><br>Constructor with medium pattern:<br>XRegExp with pattern cache flush x 32,622 ops/sec ±2.64% (72 runs sampled)<br>XRegExp x 294,758 ops/sec ±2.03% (73 runs sampled)<br>XRegExp.cache x 36,729,360 ops/sec ±2.02% (72 runs sampled)<br>RegExp x 608,069 ops/sec ±2.22% (71 runs sampled)<br>Fastest is XRegExp.cache<br><br>Constructor with long pattern:<br>XRegExp with pattern cache flush x 1,523 ops/sec ±1.03% (76 runs sampled)<br>XRegExp x 73,230 ops/sec ±2.42% (70 runs sampled)<br>XRegExp.cache x 38,266,778 ops/sec ±0.87% (78 runs sampled)<br>RegExp x 84,099 ops/sec ±1.53% (76 runs sampled)<br>Fastest is XRegExp.cache<br><br>Constructor with x flag, whitespace, and comments:<br>XRegExp with pattern cache flush x 75,103 ops/sec ±1.31% (73 runs sampled)<br>XRegExp x 282,276 ops/sec ±2.80% (73 runs sampled)<br>XRegExp.cache x 34,972,939 ops/sec ±3.18% (69 runs sampled)<br>Fastest is XRegExp.cache<br><br>exec:<br>Native exec x 78,870 ops/sec ±1.12% (81 runs sampled)<br>Shimmed exec x 78,755 ops/sec ±0.65% (84 runs sampled)<br>XRegExp.exec x 78,950 ops/sec ±0.88% (81 runs sampled)<br>Fastest is XRegExp.exec,Shimmed exec,Native exec<br><br>exec with 200000 different strings:<br>Native exec x 78,312 ops/sec ±1.23% (81 runs sampled)<br>Shimmed exec x 79,168 ops/sec ±0.79% (81 runs sampled)<br>XRegExp.exec x 79,050 ops/sec ±0.72% (81 runs sampled)<br>Fastest is Shimmed exec,XRegExp.exec,Native exec<br><br>Sticky exec with 200000 different strings:<br>Native exec x 79,729 ops/sec ±0.69% (82 runs sampled)<br>Shimmed exec x 79,183 ops/sec ±0.76% (81 runs sampled)<br>XRegExp.exec x 79,968 ops/sec ±0.81% (81 runs sampled)<br>Fastest is XRegExp.exec,Native exec,Shimmed exec<br><br>Iteration with a nonglobal regex:<br>replace with callback x 27,795 ops/sec ±0.81% (82 runs sampled)<br>while/exec x 50,836 ops/sec ±2.55% (78 runs sampled)<br>while/XRegExp.exec x 40,830 ops/sec ±0.70% (81 runs sampled)<br>XRegExp.forEach x 33,478 ops/sec ±2.14% (74 runs sampled)<br>Fastest is while/exec<br><br>Regex object type:<br>RegExp object x 98,341 ops/sec ±0.72% (83 runs sampled)<br>XRegExp object x 96,449 ops/sec ±1.30% (79 runs sampled)<br>Fastest is RegExp object,XRegExp object<br><br>Capturing:<br>Numbered capture x 97,005 ops/sec ±0.95% (78 runs sampled)<br>Named capture (one name) x 95,668 ops/sec ±1.11% (82 runs sampled)<br>Named capture (four names) x 79,571 ops/sec ±0.90% (82 runs sampled)<br>Fastest is Numbered capture,Named capture (one name)<br><br>Unicode letter construction:<br>Incomplete set: /[a-z]/i x 95,038 ops/sec ±2.00% (79 runs sampled)<br>BMP only: /\p{L}/ x 93,437 ops/sec ±1.29% (81 runs sampled)<br>Full Unicode: /\p{L}/A x 95,982 ops/sec ±1.76% (81 runs sampled)<br>Fastest is Full Unicode: /\p{L}/A,Incomplete set: /[a-z]/i<br><br>Unicode letter matching:<br>a-z caseless x 214,699 ops/sec ±0.71% (83 runs sampled)<br>\p{L} x 96,087 ops/sec ±0.73% (85 runs sampled)<br>\p{L} astral x 14,646 ops/sec ±0.77% (83 runs sampled)<br>Fastest is a-z caseless<br><br>Unicode word matching:<br>a-z caseless x 87,168 ops/sec ±0.69% (82 runs sampled)<br>\p{L} x 27,299 ops/sec ±0.94% (84 runs sampled)<br>\p{L} astral x 3,405 ops/sec ±1.08% (80 runs sampled)<br>Fastest is a-z caseless<br><br>Finished. ☺</div>
</tr></table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment