-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path_test.js
More file actions
40 lines (38 loc) · 912 Bytes
/
_test.js
File metadata and controls
40 lines (38 loc) · 912 Bytes
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
34
35
36
37
38
39
40
const ProceduralLambda = require('./procedural-lambda');
const lbd = new ProceduralLambda()
.map((_,i) => 101+i)
.filter(v => v % 2 === 0)
.reduce((accum,v) => accum+v, 0);
new require('benchmark').Suite()
.add('procedural', () => {
let suma = 0;
for(let i = 100; i <= 1000; i++){
if(i % 2 === 0)
suma++;
}
if(suma != 450)
return new Error('Logic Fault');
return suma;
})
.add('functional', () => {
const suma = Array.apply(null, Array(899))
.map((_,i) => 101+i)
.filter(v => v % 2 === 0)
.reduce((a,b) => a+b, 0);
if(suma != 450)
return new Error('Logic Fault');
return suma;
})
.add('lbd', () => {
const suma = lbd.execute(Array.apply(null, Array(899)))
if(suma != 450)
return new Error('Logic Fault');
return suma;
})
.on('cycle', (ev) => {
console.log(String(ev.target));
})
.on('complete', function() {
console.log(`Fastest: ${this.filter('fastest').map('name')}\n`);
})
.run();