-
Notifications
You must be signed in to change notification settings - Fork 17
/
benchmark.js
39 lines (35 loc) · 1.12 KB
/
benchmark.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
'use strict';
const Benchmark = require('benchmark');
const {formatSubunitAmount, formattingForLocale} = require('.');
const intlFormatter = Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' });
const formatting = formattingForLocale('de-DE', 'EUR');
new Benchmark.Suite('')
.add('big number', () => {
formatSubunitAmount(100052233, formatting);
})
.add('big negative number', () => {
formatSubunitAmount(-100052233, formatting);
})
.add('middle number', () => {
formatSubunitAmount(120004, formatting);
})
.add('small number', () => {
formatSubunitAmount(1234, formatting);
})
.add('big number intl', () => {
intlFormatter.format(100052233);
})
.add('big negative number intl', () => {
intlFormatter.format(-100052233);
})
.add('middle number intl', () => {
intlFormatter.format(120004);
})
.add('small number intl', () => {
intlFormatter.format(1234);
})
// add listeners
.on('cycle', (event) => {
// tslint:disable-next-line
console.log(String(event.target));
}).run();