Created
August 17, 2011 21:11
-
-
Save fphilipe/1152644 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixnum | |
user system total real | |
true | |
0.030000 0.000000 0.030000 ( 0.027810) | |
true | |
0.010000 0.000000 0.010000 ( 0.006959) | |
-------------------------------------------------- | |
String | |
user system total real | |
true | |
0.030000 0.000000 0.030000 ( 0.027461) | |
true | |
0.000000 0.000000 0.000000 ( 0.007344) | |
-------------------------------------------------- | |
Array | |
user system total real | |
true | |
0.030000 0.000000 0.030000 ( 0.027043) | |
true | |
0.010000 0.000000 0.010000 ( 0.007165) | |
-------------------------------------------------- | |
Hash | |
user system total real | |
true | |
0.020000 0.000000 0.020000 ( 0.026982) | |
true | |
0.010000 0.000000 0.010000 ( 0.007160) | |
-------------------------------------------------- | |
Range | |
user system total real | |
true | |
0.030000 0.000000 0.030000 ( 0.026966) | |
true | |
0.010000 0.000000 0.010000 ( 0.007119) | |
-------------------------------------------------- | |
Symbol | |
user system total real | |
true | |
0.020000 0.000000 0.020000 ( 0.027621) | |
true | |
0.010000 0.000000 0.010000 ( 0.006903) | |
-------------------------------------------------- | |
Regexp | |
user system total real | |
true | |
0.030000 0.000000 0.030000 ( 0.026712) | |
true | |
0.000000 0.000000 0.000000 ( 0.007167) | |
-------------------------------------------------- | |
Class | |
user system total real | |
true | |
0.030000 0.000000 0.030000 ( 0.027748) | |
true | |
0.010000 0.000000 0.010000 ( 0.007405) | |
-------------------------------------------------- | |
Object | |
user system total real | |
true | |
0.030000 0.000000 0.030000 ( 0.027256) | |
true | |
0.000000 0.000000 0.000000 ( 0.006655) | |
-------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
x = [ | |
123, | |
'abc', | |
[9, 'z'], | |
{ :y => 8 }, | |
1..100, | |
:sym, | |
/\Atest(?:|ing)\z/, | |
Object, | |
Object.new | |
] | |
x.each do |i| | |
puts i.class | |
a = b = nil | |
Benchmark.bm do |bm| | |
bm.report do | |
100_000.times do | |
a, b = [i] * 2 | |
end | |
puts a.object_id == b.object_id | |
end | |
bm.report do | |
100_000.times do | |
a = b = i | |
end | |
puts a.object_id == b.object_id | |
end | |
end | |
puts '-' * 50 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment