output time of function calls

This commit is contained in:
Ryan Dahl 2010-09-28 01:14:38 -07:00
parent 353e2565d5
commit f9d6b074cf

View File

@ -30,6 +30,14 @@ for (i = 0; i < N; i++) {
var cxxDiff = new Date() - start;
console.log(N +" C++ function calls: " + cxxDiff);
function toMicro (diff) {
return (diff / N) * 1000000;
}
console.log("\nJS function call speed: %d microseconds", toMicro(jsDiff));
console.log("C++ function call speed: %d microseconds", toMicro(cxxDiff));
console.log("\nJS speedup " + (cxxDiff / jsDiff));