From f9d6b074cf75a250ccc705f51e7d71a85803085b Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 28 Sep 2010 01:14:38 -0700 Subject: [PATCH] output time of function calls --- benchmark/function_call/bench.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/benchmark/function_call/bench.js b/benchmark/function_call/bench.js index f195842ca3..55e6ea116f 100644 --- a/benchmark/function_call/bench.js +++ b/benchmark/function_call/bench.js @@ -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));