-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
33 lines (32 loc) · 783 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
// add tests
suite.add('Sergii', function() {
for (var n = 1; n <= 1000; n++) {
var output = '';
if (n % 3 === 0) {
output += 'fiz'
}
if (n % 5 === 0) {
output += 'baz'
}
output || n
// console.log(output || n);
}
})
.add('Denys', function() {
let a = [];
a[0] = 'fizzbuzz';
a[3] = a[6] = a[9] = a[12] = 'fizz';
a[5] = a[10] = 'buzz';
[...Array(1000).keys()].map(i => a[++i%15]||i); // console.log removed to clear tests results
})
// add listeners
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
// run async
.run({ 'async': true });