-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from dterei/master
New timeout handling to fix issue #52
- Loading branch information
Showing
8 changed files
with
205 additions
and
72 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/*jshint node: true */ | ||
/*jslint unparam: true*/ | ||
'use strict'; | ||
|
||
/** | ||
* Check how fast various timers are in node. | ||
*/ | ||
|
||
var Benchmark = require('benchmark'); | ||
var Microtime = require('microtime'); | ||
|
||
var suite = new Benchmark.Suite(); | ||
|
||
// add tests | ||
suite.add('Date.now()', function() { | ||
// system time, not-monotonic, ms | ||
Date.now(); | ||
}) | ||
.add('Microtime.now()', function() { | ||
// system time, not-monotonic, us (POSIX: gettimeofday) | ||
Microtime.now(); | ||
}) | ||
.add('process.hrtime()', function() { | ||
// monotonic, ns (returns: [seconds, nanoseconds]) | ||
process.hrtime(); | ||
}) | ||
.add('process.hrtime() ms-round', function() { | ||
// monotonic, ns (returns: [seconds, nanoseconds]) | ||
var time = process.hrtime(); | ||
return (time[0] * 1000) + Math.round(time[1] / 1000000); | ||
}) | ||
.add('process.hrtime() ms-floor', function() { | ||
// monotonic, ns (returns: [seconds, nanoseconds]) | ||
var time = process.hrtime(); | ||
return (time[0] * 1000) + Math.floor(time[1] / 1000000); | ||
}) | ||
// add listeners | ||
.on('cycle', function(event) { | ||
console.log(String(event.target)); | ||
}) | ||
.on('complete', function() { | ||
console.log('Fastest is ' + this.filter('fastest').map('name')); | ||
}) | ||
// run async | ||
.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
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
Oops, something went wrong.