Browse Source

output time of function calls

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
f9d6b074cf
  1. 8
      benchmark/function_call/bench.js

8
benchmark/function_call/bench.js

@ -30,6 +30,14 @@ for (i = 0; i < N; i++) {
var cxxDiff = new Date() - start; var cxxDiff = new Date() - start;
console.log(N +" C++ function calls: " + cxxDiff); 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)); console.log("\nJS speedup " + (cxxDiff / jsDiff));

Loading…
Cancel
Save