2 ms·
The second benchmark isn't particularly fair. We're supposed to be testing == speed, not object creation. It should be something like: test_str1, test_str2 =
by BFalkner 18y ago
The second benchmark isn't particularly fair. We're supposed to be testing == speed, not object creation. It should be something like:
test_str1, test_str2 = "test", "test"
str = Benchmark.measure do
10_000_000.times do
test_str1 == test_str2
end
end.total
testsym1, testsym2 = :test, :test
sym = Benchmark.measure do
10_000_000.times do
testsym1 == testsym2
end
end.total
Of course you might not need to create two strings, and definitely not two symbols. Somebody want to run this? (I'm on a communal computer with no Ruby.)