-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbench.js
36 lines (33 loc) · 820 Bytes
/
bench.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
import Benchmark from 'benchmark'
import pluralize from 'numd'
import createTranslate from './src'
import translation from './fixture'
let translate
new Benchmark.Suite()
.add('createTranslate', () => {
translate = createTranslate(translation, {pluralize})
})
.on('cycle', event => {
console.log(String(event.target))
})
.run()
new Benchmark.Suite()
.add('base translate', () => {
translate('string')
})
.add('nested translate', () => {
translate('nested.string')
})
.add('array translate', () => {
translate('array.0')
})
.add('translate with param', () => {
translate('nested.param', 'param')
})
.add('translate with function', () => {
translate('nested.complex', 'param', 2)
})
.on('cycle', event => {
console.log(String(event.target))
})
.run()