JRuby 震惊啊,能不能说现在 jruby 有了大杀器呢?

fsword · November 21, 2012 · Last by fsword replied at November 23, 2012 · 7901 hits

早上一上推就看到这个项目 https://github.com/flatland/drip/wiki/JRuby ,简单试了一下:

$ time java -cp jruby.jar org.jruby.Main -e 'puts 1000.times.to_a.reduce(:+)'
499500

real    0m1.506s
user    0m1.884s
sys 0m0.112s
~[1.9.3]
$ time drip -cp jruby.jar org.jruby.Main -e 'puts 1000.times.to_a.reduce(:+)'
499500

real    0m0.252s
user    0m0.028s
sys 0m0.016s

jruby 最头疼的就是启动慢,现在有很大改善啊,有空再试试 load、require 的速度

貌似做法是没事就准备一个 jvm, drip 时把准备好的送出去,然后马上启动下一轮要用到的 jvm, 对执行间隔至少几秒的脚本效果明显,但对于在 shell prompt 中使用的脚本 (貌似就我有这种 corner case...) 没用... 另外貌似 jvm 的环境变量会滞后一轮 ?

#1 楼 @luikore 实践中好像对 shell prompt 优势应该也很明显,只要你的脚本里都改用 drip,不过我也不明白它是怎么做到的,粗看了一下代码,好象就是你说的方法,提前准备进程,问题是一开始使用就很快,那是怎么准备的呢?困惑

You need to Sign in before reply, if you don't have an account, please Sign up first.