Created
December 20, 2016 09:53
-
-
Save bigopon/b06f276129f58ec3422e8886cddb9af4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>GistRun</title> | |
</head> | |
<body> | |
<pre><code id="status"></code></pre> | |
<script src="https://cdn.jsdelivr.net/g/[email protected],[email protected],[email protected]"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/node-uuid/1.4.7/uuid.js"></script> | |
<script src="script.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
function log(message) { | |
document.getElementById('status').textContent += message + '\n'; | |
} | |
log('running...'); | |
const tests = [ | |
'data-au-target-id', | |
'aria-target-id', | |
'ng:if', | |
'v-on:click' | |
]; | |
// add tests | |
const suite = new Benchmark.Suite; | |
suite.add('capturing', function() { | |
let i = tests.length; | |
while (i--) { | |
/(^data-)|(^aria-)|:/.test(tests[i]); | |
} | |
}) | |
.add('non capturing', function() { | |
let i = tests.length; | |
while (i--) { | |
/(?:^data-)|(?:^aria-)|:/.test(tests[i]); | |
} | |
}) | |
// add listeners | |
.on('cycle', function(event) { | |
log(String(event.target)); | |
}) | |
.on('complete', function() { | |
log('Fastest is: ' + this.filter('fastest').map('name')); | |
}) | |
// run async | |
.run({ 'async': true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment