Created
April 13, 2014 04:44
-
-
Save bertomartin/10569564 to your computer and use it in GitHub Desktop.
This file contains 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 'bench_press' | |
extend BenchPress | |
data = [[%w{a b c d e f}, %w{d e f g h i}], [%w{a b c d e f}, %w{g h i j k l}]] | |
data.each_with_index do |(a, b), i| | |
measure "arithmetic operators ##{i+1}" do | |
a + (b - a) | |
end | |
measure "uniq ##{i+1}" do | |
(a + b).uniq | |
end | |
measure "uniq! ##{i+1}" do | |
(a + b).uniq! | |
end | |
measure "union ##{i+1}" do | |
a | b | |
end | |
end |
This file contains 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
Combining Arrays | |
================ | |
Date: June 23, 2011 | |
System Information | |
------------------ | |
Operating System: Ubuntu 11.04 | |
CPU: Intel(R) Core(TM)2 Quad CPU Q9300 @ 2.50GHz | |
Processor Count: 4 | |
Memory: 3.87 GB | |
ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux] | |
"arithmetic operators #2" is up to 30% faster over 1,000 repetitions | |
-------------------------------------------------------------------- | |
arithmetic operators #2 0.00320291519165039 secs Fastest | |
arithmetic operators #1 0.00329899787902832 secs 2% Slower | |
uniq! #2 0.00386905670166016 secs 17% Slower | |
uniq #2 0.00391983985900879 secs 18% Slower | |
union #1 0.00416898727416992 secs 23% Slower | |
uniq! #1 0.00430393218994141 secs 25% Slower | |
union #2 0.00440812110900879 secs 27% Slower | |
uniq #1 0.00458908081054688 secs 30% Slower |
This file contains 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
Combining Arrays | |
================ | |
Date: June 23, 2011 | |
System Information | |
------------------ | |
Operating System: Ubuntu 11.04 | |
CPU: Intel(R) Core(TM)2 Quad CPU Q9300 @ 2.50GHz | |
Processor Count: 4 | |
Memory: 3.87 GB | |
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux] | |
"arithmetic operators #1" is up to 72% faster over 1,000 repetitions | |
-------------------------------------------------------------------- | |
arithmetic operators #1 0.0026226043701171875 secs Fastest | |
arithmetic operators #2 0.0030150413513183594 secs 13% Slower | |
uniq! #1 0.00484919548034668 secs 45% Slower | |
uniq #1 0.004903078079223633 secs 46% Slower | |
union #1 0.005164146423339844 secs 49% Slower | |
uniq! #2 0.009515762329101562 secs 72% Slower | |
union #2 0.009597301483154297 secs 72% Slower | |
uniq #2 0.009701251983642578 secs 72% Slower |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment