/
index.js
40 lines (36 loc) · 942 Bytes
/
index.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
34
35
36
37
38
39
40
import Benchmark from 'benchmark'
import * as R from 'ramda'
import hyperid from 'hyperid'
import SubX from '../src/index'
const uuid = hyperid()
const store = SubX.create({
todos: []
})
const suite1 = new Benchmark.Suite()
suite1
.add('array push', () => {
R.range(0, 1000).forEach(i => store.todos.push({ title: i, completed: false }))
})
.on('cycle', function (event) {
console.log(String(event.target))
})
.on('complete', function () {
console.log('Fastest is ' + this.filter('fastest').map('name'))
})
.run()
const suite2 = new Benchmark.Suite()
let id = 0
suite2
.add('fake uuid', () => {
R.range(0, 100000).forEach(i => ++id)
})
.add('hyperid', () => {
R.range(0, 100000).forEach(i => uuid())
})
.on('cycle', function (event) {
console.log(String(event.target))
})
.on('complete', function () {
console.log('Fastest is ' + this.filter('fastest').map('name'))
})
.run()