Skip to content

Instantly share code, notes, and snippets.

@bigopon
Created December 20, 2016 09:53
Show Gist options
  • Save bigopon/b06f276129f58ec3422e8886cddb9af4 to your computer and use it in GitHub Desktop.
Save bigopon/b06f276129f58ec3422e8886cddb9af4 to your computer and use it in GitHub Desktop.
<!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/lodash@4.12.0,platform.js@1.3.1,benchmarkjs@2.1.0"></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>
'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