Last active
August 29, 2015 14:22
-
-
Save d4rky-pl/a34d4ec5d2b40447bcd6 to your computer and use it in GitHub Desktop.
Benchmarking ExecJS with therubyracer and node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'execjs' | |
require 'therubyracer' | |
js_code = '2+2' | |
STDOUT.sync = true | |
ExecJS.runtime = ExecJS::Runtimes::Node | |
Benchmark.bmbm(20) do |benchmark| | |
benchmark.report('node.js') do | |
100.times { ExecJS.eval(js_code) } | |
end | |
end | |
ExecJS.runtime = ExecJS::Runtimes::RubyRacer | |
Benchmark.bmbm(20) do |benchmark| | |
benchmark.report('therubyracer') do | |
100.times { ExecJS.eval(js_code) } | |
end | |
end | |
# RESULTS: | |
# | |
# Rehearsal ------------------------------------------------ | |
# node.js 0.080000 0.050000 11.200000 ( 11.602124) | |
# -------------------------------------- total: 11.200000sec | |
# | |
# user system total real | |
# node.js 0.070000 0.050000 11.180000 ( 11.570431) | |
# Rehearsal ------------------------------------------------ | |
# therubyracer 0.060000 0.020000 0.080000 ( 0.064798) | |
# --------------------------------------- total: 0.080000sec | |
# | |
# user system total real | |
# therubyracer 0.060000 0.010000 0.070000 ( 0.069190) | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment