From ad076621f7119835a50fc9eada610b2394e4d2b2 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 22 Dec 2014 18:47:29 -0800 Subject: [PATCH] Add benchmark script --- test/bench_execjs.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/bench_execjs.rb diff --git a/test/bench_execjs.rb b/test/bench_execjs.rb new file mode 100644 index 0000000..5feff02 --- /dev/null +++ b/test/bench_execjs.rb @@ -0,0 +1,20 @@ +require 'benchmark' +require 'execjs' + +TIMES = 10 +SOURCE = File.read(File.expand_path("../fixtures/coffee-script.js", __FILE__)).freeze + +Benchmark.bmbm do |x| + ExecJS::Runtimes.runtimes.each do |runtime| + next if !runtime.available? || runtime.deprecated? + + x.report(runtime.name) do + ExecJS.runtime = runtime + context = ExecJS.compile(SOURCE) + + TIMES.times do + context.call("CoffeeScript.eval", "((x) -> x * x)(8)") + end + end + end +end