Created
April 17, 2012 16:56
-
-
Save shyouhei/2407477 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 'benchmark' | |
a = Array.new(4096) { [rand(1 << 64), rand(1 << 64)] } | |
n = 1 << 32 | |
Benchmark.bmbm do |x| | |
x.report do | |
a.collect do |b| | |
a.select do |c| | |
n >= Math.sqrt( | |
(b[0] - c[0]) ** 2 + (b[1] - c[1]) ** 2 | |
) | |
end | |
end | |
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
Rehearsal ------------------------------------ | |
88.860000 3.410000 92.270000 ( 92.315821) | |
-------------------------- total: 92.270000sec | |
user system total real | |
85.220000 3.690000 88.910000 ( 88.928956) |
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
Rehearsal ------------------------------------ | |
122.530000 0.340000 122.870000 (122.910743) | |
------------------------- total: 122.870000sec | |
user system total real | |
119.470000 0.050000 119.520000 (119.579139) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment