1
0
Fork 0
mirror of https://github.com/rubyjs/mini_racer synced 2023-03-27 23:21:28 -04:00
mini_racer/benchmarks/bench_uglify.rb

41 lines
1 KiB
Ruby
Raw Normal View History

2016-05-14 09:14:14 -04:00
engines = {
2016-05-16 01:58:19 -04:00
mini_racer: proc { ExecJS::MiniRacerRuntime.new },
therubyracer: proc { ExecJS::RubyRacerRuntime.new },
rhino: proc { ExecJS::RubyRhinoRuntime.new },
duktape: proc { ExecJS::DuktapeRuntime.new},
node: proc { ExecJS::Runtimes::Node }
2016-05-14 09:14:14 -04:00
}
engine = ARGV[0]
2016-05-16 01:58:19 -04:00
unless engine && (execjs_engine = engines[engine.to_sym])
2016-05-14 09:14:14 -04:00
STDERR.puts "Unknown engine try #{engines.keys.join(',')}"
exit 1
2016-05-11 22:41:33 -04:00
end
2016-05-14 09:14:14 -04:00
unless engine == "node"
require engine
end
2016-05-16 01:58:19 -04:00
2016-05-14 09:14:14 -04:00
puts "Benching with #{engine}"
2016-05-11 22:41:33 -04:00
require 'uglifier'
2016-05-16 01:58:19 -04:00
ExecJS.runtime = execjs_engine.call
2016-05-11 22:41:33 -04:00
start = Time.new
Uglifier.compile(File.read("discourse_app.js"))
puts "#{engine} minify discourse_app.js #{(Time.new - start)*1000}ms"
start = Time.new
Uglifier.compile(File.read("discourse_app_minified.js"))
puts "#{engine} minify discourse_app_minified.js #{(Time.new - start)*1000}ms"
start = Time.new
(0..1).map do
Thread.new do
Uglifier.compile(File.read("discourse_app.js"))
end
end.each(&:join)
puts "#{engine} minify discourse_app.js twice (2 threads) #{(Time.new - start)*1000}ms"