blob: 12256e180d34de5fd3d744354a772437383b222c (
plain)
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
|
import Benchmark from 'benchmark';
import { ICU4XFixedDecimal } from "../index.js"
let suite = new Benchmark.Suite();
suite = suite.add("ICU4XFixedDecimal.create_from_i64", () => {
(ICU4XFixedDecimal.create_from_i64(BigInt(1234))).underlying > 0;
});
const decimal = ICU4XFixedDecimal.create_from_i64(BigInt(1234));
decimal.multiply_pow10(-2);
suite = suite.add("ICU4XFixedDecimal.to_string", () => {
decimal.to_string();
});
suite = suite.add("ICU4XFixedDecimal.multiply_pow10", () => {
decimal.multiply_pow10(2);
decimal.multiply_pow10(-2);
});
suite = suite.add("ICU4XFixedDecimal.set_sign", () => {
decimal.set_sign("Negative");
decimal.set_sign("None");
});
suite
.on('cycle', (event) => {
console.log(String(event.target));
console.log('μs/it:', event.target.stats.mean * 1000 * 1000);
console.log();
})
.run({ "async": false });
|