mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
Add benchmark script
This commit is contained in:
parent
898dc5e32e
commit
ad076621f7
1 changed files with 20 additions and 0 deletions
20
test/bench_execjs.rb
Normal file
20
test/bench_execjs.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue