Hello,
I’ve been successfully using JRuby from within Java for some time and
now I’m trying to improve the startup time. The code is available as an
open source project called LESS Engine [1] and wraps a cool Ruby library
for CSS called LESS [2].
Here is the test code I’m currently using:
List loadPaths = new ArrayList();
loadPaths.add(“META-INF/jruby.home/lib/ruby/site_ruby/1.8”);
loadPaths.add(“META-INF/less/lib”);
loadPaths.add(“META-INF/mutter/lib”);
loadPaths.add(“META-INF/polyglot/lib”);
loadPaths.add(“META-INF/treetop/lib”);
runtime = JavaEmbedUtils.initialize(loadPaths); // takes 2852ms
adapter = JavaEmbedUtils.newRuntimeAdapter(); // takes 1ms
adapter.eval(runtime, “require ‘less’”); // takes 7893ms
adapter.eval(runtime, "require ‘less’ \nLess::Engine.new('div { width: 1
- 1 }').to_css"); // 39ms
After the first eval() everything runs smoothly. Any ideas how the above
can be optimized are welcome.
I’m running the test using JRuby 1.4 and Maven 2.2.1. My Java version
is:
Java™ SE Runtime Environment (build 1.6.0_17-b04-248-9M3125)
Java HotSpot™ 64-Bit Server VM (build 14.3-b01-101, mixed mode)
Thanks!
[1] GitHub - asual/lesscss-engine: LESS Engine - A Java wrapper for less.js
[2] GitHub - less/less.ruby: Less Ruby — now at http://github.com/cowboyd/less.rb