Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
37 additions
and
53 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,23 +1,21 @@ | ||
|
||
// run 500 times so that we can abstract out the overhead of promise creation. | ||
// run many times so that we can abstract out the overhead of promise creation. | ||
var count = 500; | ||
|
||
exports.countPerLap = count; | ||
exports.compare = { | ||
nextTick : function () { | ||
var p = new process.Promise(), i = 0; | ||
nextTick : function (done) { | ||
var i = 0; | ||
process.nextTick(function () { | ||
if (i ++ > count) p.emitSuccess(); | ||
if (i ++ > count) done(); | ||
else process.nextTick(arguments.callee); | ||
}); | ||
return p; | ||
}, | ||
setTimeout : function () { | ||
var p = new process.Promise(), i = 0; | ||
setTimeout : function (done) { | ||
var i = 0; | ||
setTimeout(function () { | ||
if (i ++ > count) p.emitSuccess(); | ||
if (i ++ > count) done(); | ||
else setTimeout(arguments.callee); | ||
}); | ||
return p; | ||
} | ||
} |
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,20 @@ | ||
#!/usr/bin/env node-bench | ||
|
||
var p = [], l = [], pi = 0, li = 0, c = 100000; | ||
|
||
exports.compare = { | ||
push : function () { | ||
if (pi === c) { | ||
p = []; | ||
pi = 0; | ||
} | ||
p.push(pi ++); | ||
}, | ||
length : function () { | ||
if (li === c) { | ||
l = []; | ||
li = 0; | ||
} | ||
l[l.length] = li ++; | ||
} | ||
} |
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