Skip to content

Instantly share code, notes, and snippets.

@besquared
Created March 25, 2009 18:58
Show Gist options
  • Select an option

  • Save besquared/85639 to your computer and use it in GitHub Desktop.

Select an option

Save besquared/85639 to your computer and use it in GitHub Desktop.
require 'benchmark'
size = 1048576
data = []
genders = ['male', 'female']
size.times do
data << [genders[rand * 2]]
end
a = 0b00
data.each_with_index do |row, index|
if row.first == 'male'
a += 1
end
end
positions = []
puts Benchmark.measure {
0.upto(size) do |position|
positions << position if a[position] == 1
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment