by Groxx · 16y ago · 0 comments
Nitpick on their array tests, however:
measure "Array#delete_if" do
a = ARRAY.dup
a.delete_if {|o| o}
end
Ah, no. If o == false, that won't delete it. Also, you're calling object == true; how about a.delete_if {true}? "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
Also:>gsubbing with string literals vs regex. For some reason regexp is faster. I suspect it converts string literals to a regexp anyway.
Really? You're surprised regex literals are faster than regex strings?
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?
I would be interested in if anyone knows how the garbage collector handles a.drop vs a = []. Maybe a.drop collects earlier, and the gc is causing the slowdown?
I'm pretty ignorant about how the GC affects these benchmarks - I'd like to investigate that further in the future.
1. Valid GC during execution: you are removing an actual factor;
2. "Invalid" i.e. unrelated GC during execution: your benchmark is too narrow in scope.