1 | const { bahttext } = require('bahttext');
|
2 | const THBText = require('thai-baht-text');
|
3 | const { ThaiBaht } = require('thai-baht-text-ts');
|
4 |
|
5 | const {bahtText} = require("../dist/index");
|
6 |
|
7 | const { convert: bahtLatest } = require('baht');
|
8 |
|
9 | const times = 100000;
|
10 | const numbers = [
|
11 | -1,
|
12 | 0,
|
13 | 0.01,
|
14 | 0.1,
|
15 | 0.11,
|
16 | 0.12,
|
17 | 0.123,
|
18 | 0.2,
|
19 | 0.21,
|
20 | 0.25,
|
21 | 0.255,
|
22 | 0.5,
|
23 | 0.75,
|
24 | 0.99,
|
25 | 0.999,
|
26 | 1,
|
27 | 10,
|
28 | 11,
|
29 | 11.25,
|
30 | 12,
|
31 | 20,
|
32 | 21,
|
33 | 22,
|
34 | 100,
|
35 | 100.5,
|
36 | 101,
|
37 | 111,
|
38 | 121,
|
39 | 567.01,
|
40 | 1000000,
|
41 | 1000001,
|
42 | 6321298,
|
43 | 10000000,
|
44 | 10034567,
|
45 | 11000000,
|
46 | 11000001,
|
47 | 20034567,
|
48 | 30034567.0,
|
49 | 100000000,
|
50 | 123456789.999,
|
51 | 1000000000,
|
52 | 1000000000000,
|
53 | 1000000000001,
|
54 | 1001000000000,
|
55 | 1001000000001,
|
56 | 1001000001001,
|
57 | 123456789012345,
|
58 | 987654321098765,
|
59 | Number.MAX_SAFE_INTEGER - 1,
|
60 | '-1',
|
61 | '0',
|
62 | '0.01',
|
63 | '0.1',
|
64 | '0.11',
|
65 | '0.12',
|
66 | '0.123',
|
67 | '0.2',
|
68 | '0.21',
|
69 | '0.25',
|
70 | '0.255',
|
71 | '0.5',
|
72 | '0.75',
|
73 | '0.99',
|
74 | '0.999',
|
75 | '1',
|
76 | '10',
|
77 | '11',
|
78 | '11.25',
|
79 | '12',
|
80 | '20',
|
81 | '21',
|
82 | '22',
|
83 | '100',
|
84 | '100.5',
|
85 | '101',
|
86 | '111',
|
87 | '121',
|
88 | '567.01',
|
89 | '1000000',
|
90 | '1000001',
|
91 | '6321298',
|
92 | '10000000',
|
93 | '10034567',
|
94 | '11000000',
|
95 | '11000001',
|
96 | '20034567',
|
97 | '30034567.0',
|
98 | '100000000',
|
99 | '123456789.999',
|
100 | '1000000000',
|
101 | '1000000000000',
|
102 | '1000000000001',
|
103 | '1001000000000',
|
104 | '1001000000001',
|
105 | '1001000001001',
|
106 | '123456789012345',
|
107 | '987654321098765',
|
108 | ];
|
109 |
|
110 | const libraries = {
|
111 |
|
112 | bahtLatest: n => bahtLatest(n),
|
113 | thaiBahtLib: n => bahtText(n),
|
114 |
|
115 |
|
116 |
|
117 |
|
118 | };
|
119 |
|
120 | Object.entries(libraries).forEach(([name, fn]) => {
|
121 | const start = new Date();
|
122 |
|
123 | new Array(times).fill(0).forEach(_ => {
|
124 | numbers.forEach(number => fn(number));
|
125 | });
|
126 |
|
127 | const end = new Date();
|
128 |
|
129 | console.log(`${name} (x${times}): ${end - start}ms`);
|
130 | }); |
\ | No newline at end of file |