-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
50 lines (41 loc) · 956 Bytes
/
Copy pathindex.html
File metadata and controls
50 lines (41 loc) · 956 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
41
42
43
44
45
46
47
48
49
50
<script src="node_modules/benchmark/benchmark.js"></script>
<script src="node_modules/wu/lib/wu.js"></script>
<script src="node_modules/lodash/lodash.js"></script>
<script src="src/lz.js"></script>
<script>
var benchmark = new Benchmark.Suite;
function bench(tests) {
console.log('Starting benchmark...');
Object.keys(tests).forEach(function (name) {
benchmark.add(name, tests[name])
})
benchmark
.on('cycle', function(event) {
console.log(String(event.target))
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').pluck('name'))
})
.run()
}
</script>
<script>
var a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
var even = function (n) {
return n % 2 === 0
}
function _lodash() {
return _.filter(a, even).shift()
}
function _lz() {
return new lz(a).filter(even).head()
}
function _wu() {
return wu(a).filter(even).next()
}
bench({
'lodash': _lodash,
'lz': _lz,
'wu': _wu
})
</script>