瞎扯淡 使用 2.7.1 后性能和内存消耗都变差了

lilijreey · 2020年09月14日 · 最后由 lilijreey 回复于 2020年09月24日 · 1916 次阅读

大家遇到过没,我打比赛相同的代码在 2.7.1 上成绩差了不少 话说 ruby VM 啥时候能优化的和 JVM 差不多就可以了

后面一个问题,用 JRuby 就可以了。

没感觉,你是跟哪一版的比?

khiav223577 回复

不知道,,,,应该是 2.6

require 'time'
filename='ruby.htm'
fp=File.open(filename,'rb')
content= fp.read
me='<div id="respond" class="no_webshot">' 

def findme(search,me)
   pos=search.index(me)
end  

pos=0
mark = Time.now.to_f
for i in 1..90000
     pos=findme(content,me)
end 

puts Time.now.to_f - mark

ruby 2.5 性能最好

tablecell 回复

说好的 x3 优化呢,是忽悠吗😂

需要 登录 后方可回复, 如果你还没有账号请 注册新账号