Last active
October 25, 2015 07:18
-
-
Save yuku/4758afde9d4b5be2064c to your computer and use it in GitHub Desktop.
execjs - therubyracer v.s. Node.js
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/ips" | |
require "execjs" | |
require "open-uri" | |
source = open("http://coffeescript.org/extras/coffee-script.js").read | |
RUNTIMES = [ | |
ExecJS::Runtimes::RubyRacer, | |
ExecJS::Runtimes::Node, | |
] | |
Benchmark.ips do |x| | |
RUNTIMES.each do |runtime| | |
x.report(runtime.name) do |renders| | |
ExecJS.runtime = runtime | |
renders.times do | |
ExecJS.eval("'red yellow blue'.split(' ')") | |
end | |
end | |
end | |
x.compare! | |
end | |
Benchmark.ips do |x| | |
RUNTIMES.each do |runtime| | |
x.report(runtime.name) do |renders| | |
ExecJS.runtime = runtime | |
context = ExecJS.compile(source) | |
renders.times do | |
context.call("CoffeeScript.compile", "square = (x) -> x * x", bare: true) | |
end | |
end | |
end | |
x.compare! | |
end |
Author
yuku
commented
Oct 25, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment