TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ruby Benchmark

80 点作者 rbxbx将近 15 年前

12 条评论

Groxx将近 15 年前
A handy list, I'll have to read through it more completely some time. There are some surprising speed differences. For instance, array.drop is hella-faster than array.clear, and array.shift(n) is faster yet (what?).<p>Nitpick on their array tests, however:<p><pre><code> measure "Array#delete_if" do a = ARRAY.dup a.delete_if {|o| o} end </code></pre> Ah, <i>no</i>. If o == false, that won't delete it. Also, you're calling object == true; how about a.delete_if {true}?<p><pre><code> "Array#delete_if{true}" is up to 30% faster over 10000 repetitions ------------------------------------------------------------------ Array#delete_if{true} 1.42472314834595 secs Fastest Array#delete_if{|o| o} 2.03995013237 secs 30% Slower </code></pre> Also:<p>&#62;<i>gsubbing with string literals vs regex. For some reason regexp is faster. I suspect it converts string literals to a regexp anyway.</i><p>Really? You're surprised regex literals are faster than regex strings?<p>The gem however is interesting and nice and simple, I may end up using it for my future testing. Haven't looked through the code, however: anyone know if it's making any mistakes?
评论 #1566099 未加载
评论 #1566044 未加载
评论 #1565973 未加载
评论 #1567336 未加载
评论 #1566971 未加载
jackowayed将近 15 年前
This is awesome. It would be really cool if they added comments so that people in the know could explain things (and possibly dispute the outcomes)
评论 #1566954 未加载
zackadams将近 15 年前
Nice work Sandro.<p>Andy Stone has a benchmark file he's been maintaining that has some similarity to your project. Check it out if your looking for inspiration on additional tests: <a href="http://github.com/stonean/benchmark/blob/master/benchmarks.rb" rel="nofollow">http://github.com/stonean/benchmark/blob/master/benchmarks.r...</a>
评论 #1566963 未加载
viraptor将近 15 年前
It doesn't seem to throw out / properly mark insignificant results: <a href="http://rubybenchmark.com/reports/10" rel="nofollow">http://rubybenchmark.com/reports/10</a> (is there any reason these 2 variants could get different bytecode results?)<p>That's the way echo -vs- print wars start...
评论 #1566947 未加载
pieter将近 15 年前
&#62; "while" is up to 92% faster over 100000 repetitions<p><pre><code> Array#each_with_index 1.3768820762634277 secs 92% Slower while 0.10703921318054199 secs Fastest </code></pre> Don't you mean it's around 13x fast (or 1200% faster)?
评论 #1567263 未加载
Pistos2将近 15 年前
Although it usually only matters when compared code scores similarly, it is important to be able to know when benchmark comparisons are <i>statistically significant</i>[1]. I wrote a library[2] a while back to do this. This becomes even more of a concern when the benchmarked code is running on a machine which is not well-isolated and dedicated to running the benchmark.<p>[1]: <a href="http://en.wikipedia.org/wiki/Statistical_significance" rel="nofollow">http://en.wikipedia.org/wiki/Statistical_significance</a><p>[2]: <a href="http://github.com/Pistos/better-benchmark" rel="nofollow">http://github.com/Pistos/better-benchmark</a>
jacquesm将近 15 年前
Funny, just finished installing rails 3 and the latest ruby. What a headache that was, really. In spite of following a tutorial I ran in to a whole series of showstoppers and only just now finally got it to work.<p>I've never played with ruby/rails before so I figured I'd better go and see what all the noise is all about but I had definitely not counted on so many installation issues.<p>I should probably clean this machine and do it all over again to be able to write up the exact steps to get it to work (from not having ruby before) but I'm too scared of having to go through another day of fiddling.
评论 #1566061 未加载
评论 #1567024 未加载
评论 #1566236 未加载
AndrewO将近 15 年前
That's a great idea. I'd really like to see a "raw" format option on the server that would give the code and metadata in a structured format.<p>With that one could write a tool that suggests improvements to code as it tests it using this as a sort of crowd-sourced benchmark suite. It may not be 100% accurate, but at least it would give verified data instead of the educated-guess strategy most of us employ now.
ulvund将近 15 年前
It might be fun to add some Date tests as well. The methods are very slow to say the least. There is a 'date/performance' gem I think.
评论 #1566952 未加载
rue将近 15 年前
I am, uh, highly sceptical of the value of this. That is, even ignoring the variance between runs of the same code, differences between implementations and within an implementation with slightly different objects.<p>Writing code based on "what is fastest" is an overall awful strategy.
justinchen将近 15 年前
How about an RSS feed for the recent benchmarks?
评论 #1566957 未加载
xsltuser2010将近 15 年前
The site is awfully slow at the moment. Is it written in Ruby ? That would make the benchmark even more convincing ;)
评论 #1566127 未加载
评论 #1566958 未加载
评论 #1566106 未加载