-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
64 lines (51 loc) · 1.98 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* For include() */
var fs = require('fs');
function read(f) { return fs.readFileSync(f).toString(); }
function include(f) { eval.apply(global, [read(f)]); }
/*******************/
/* Import Packages */
/*******************/
// Develoka - Angka Terbilang
// https://github.com/develoka/angka-terbilang-js
const angkaTerbilang = require('@develoka/angka-terbilang-js');
// Dikyarga - Angka Menjadi Terbilang
// https://github.com/dikyarga/angka-menjadi-terbilang
const angkaMenjadiTerbilang = require('angka-menjadi-terbilang');
// BosNaufal - Terbilang
// https://github.com/BosNaufal/terbilang-js
include('node_modules/terbilang-js/terbilang.js');
// DimasKiddo - Angka Terbilang NodeJS
// https://github.com/dimaskiddo/angka-terbilang-nodejs
const angka = require('@dimaskiddo/angka-terbilang-nodejs')
// rimara14 - terbilang
// https://github.com/rimara14/terbilang
const terbilangRimara = require("angka-terbilang/dist/number-to-string");
/*******************/
/* Run Benchmarks */
/*******************/
// Import the benchtable module
var BenchTable = require('benchtable');
// Create benchtable suite
var suite = new BenchTable();
suite
// Add functions for benchmarking
.addFunction('@develoka/angka-terbilang-js', s => angkaTerbilang(s))
.addFunction('dikyarga/angka-menjadi-terbilang', s => angkaMenjadiTerbilang(s))
.addFunction('BosNaufal/terbilang-js', s => terbilang(s))
.addFunction('DimasKiddo/angka-terbilang-nodejs', s => angka.toTerbilang(s))
.addFunction('rimara14/terbilang', s => terbilangRimara.default(s))
// Add inputs
.addInput('Ratusan Ribu', ['618277'])
.addInput('Ratusan Juta', ['120019212'])
.addInput('Ratusan Milyar', ['999120019212'])
.addInput('Ratusan Triliun', ['865999120019212'])
// Add listeners
.on('cycle', event => {
console.log(event.target.toString());
})
.on('complete', () => {
console.log('Fastest is ' + suite.filter('fastest').map('name'));
console.log(suite.table.toString());
})
// Run async
.run({ async: false });