-
Para executar instale o Node.js
-
Crie um projeto/pasta e instale o Benchmark.js:
mkdir exemplo1 cd exemplo1 npm i --save benchmark
-
Execute o comando
node index.js
Deve obter algo como:
Math x 952,800,308 ops/sec ±0.21% (96 runs sampled)
while x 10,586,158 ops/sec ±0.96% (86 runs sampled)
padEnd x 11,894,867 ops/sec ±2.97% (88 runs sampled)
substring x 26,682,987 ops/sec ±1.95% (87 runs sampled)
Fastest is Math