Skip to content

Instantly share code, notes, and snippets.

@niieani
Created June 25, 2016 23:44
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 niieani/410488619bc27cdd4f1ba222de9c5dbe to your computer and use it in GitHub Desktop.
Save niieani/410488619bc27cdd4f1ba222de9c5dbe to your computer and use it in GitHub Desktop.
Benchmark
<html>
<head>
<script src="https://wzrd.in/bundle/lodash@4.11"></script>
<script src="https://wzrd.in/bundle/platform@1.3"></script>
<script src="https://wzrd.in/bundle/benchmark@2.1"></script>
</head>
<body>
<script>
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
// add tests
suite.add('FirstTest', function() {
// first test here
})
.add('SecondTest', function() {
// second test here
})
// add listeners
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
// run tests async
.run({ 'async': true });
</script>
</body>
</html>
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
// add tests
suite.add('FirstTest', function() {
// first test here
})
.add('SecondTest', function() {
// second test here
})
// add listeners
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
// run tests async
.run({ 'async': true });
/* todo: add styles */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment