Last active
June 7, 2017 18:14
-
-
Save thevtm/063a834083a42af535e26196a5d3c8d5 to your computer and use it in GitHub Desktop.
[Benchmark] ms vs Delagen/ms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
/* | |
Modules | |
*/ | |
var Benchmark = require('benchmark') | |
var ms = require('ms') | |
var msNew = require('ms-new') | |
var msMine = require('ms-mine') | |
/* | |
Benchmark | |
Results: | |
original x 38,472 ops/sec ±2.05% (88 runs sampled) | |
new x 39,713 ops/sec ±1.89% (82 runs sampled) | |
mine x 74,820 ops/sec ±1.84% (84 runs sampled) | |
Fastest is mine | |
Done in 17.97s. | |
*/ | |
var suite = new Benchmark.Suite; | |
suite.add('original', function() { | |
ms('100'); | |
ms('1m'); | |
ms('1h'); | |
ms('2d'); | |
ms('1s'); | |
ms('100ms'); | |
ms('1.5h'); | |
ms('1 s'); | |
ms('1.5H') | |
ms('.5ms'); | |
ms('1'.repeat(49) + 'h'); | |
ms('2'.repeat(49) + 'Z'); | |
ms('3'.repeat(998) + 'd'); | |
ms('4'.repeat(998) + 'x'); | |
}) | |
.add('new', function() { | |
msNew('100'); | |
msNew('1m'); | |
msNew('1h'); | |
msNew('2d'); | |
msNew('1s'); | |
msNew('100ms'); | |
msNew('1.5h'); | |
msNew('1 s'); | |
msNew('1.5H') | |
msNew('.5ms'); | |
msNew('1'.repeat(49) + 'h'); | |
msNew('2'.repeat(49) + 'Z'); | |
msNew('3'.repeat(998) + 'd'); | |
msNew('4'.repeat(998) + 'x'); | |
}) | |
.add('mine', function() { | |
msMine('100'); | |
msMine('1m'); | |
msMine('1h'); | |
msMine('2d'); | |
msMine('1s'); | |
msMine('100ms'); | |
msMine('1.5h'); | |
msMine('1 s'); | |
msMine('1.5H') | |
msMine('.5ms'); | |
msMine('1'.repeat(49) + 'h'); | |
msMine('2'.repeat(49) + 'Z'); | |
msMine('3'.repeat(998) + 'd'); | |
msMine('4'.repeat(998) + 'x'); | |
}) | |
.on('cycle', function(event) { | |
console.log(String(event.target)); | |
}) | |
.on('complete', function() { | |
console.log('Fastest is ' + this.filter('fastest').map('name')); | |
}) | |
.run({ 'async': true }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "ms-benchmark", | |
"version": "1.0.0", | |
"main": "main.js", | |
"author": "Vinícius T. M.", | |
"license": "MIT", | |
"scripts": { | |
"start": "node main.js" | |
}, | |
"dependencies": { | |
"benchmark": "^2.1.4", | |
"ms": "git+https://github.com/zeit/ms.git", | |
"ms-new": "git+https://github.com/Delagen/ms.git", | |
"ms-mine": "git+https://github.com/TheVTM/ms.git" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment