Skip to content

Instantly share code, notes, and snippets.

@jonelf
Created May 28, 2012 13:48
Show Gist options
  • Save jonelf/2819303 to your computer and use it in GitHub Desktop.
Save jonelf/2819303 to your computer and use it in GitHub Desktop.
require 'benchmark'
@properties = []
1.upto(10000) do
@properties << {
Strasse:"Oberdorfstrasse",
StrassenNr:6,
Plz:6277,
Ort:"Lieli",
Preis:600,
Flache:70,
Zimmer:2,
Lift:true,
Verfugbarkeit:7,
Keller:false,
Neubau:true,
OV:false
}
end
def search
found = 0
@properties.each do |p|
found +=1 if p[:Strasse] == "Oberdorfstrasse" &&
p[:StrassenNr] == 6 && p[:Plz] == 6277 &&
p[:Ort] == "Lieli" &&
p[:Preis] >= 500 && p[:Preis] <= 1000 &&
p[:Flache] >= 10 && p[:Flache] <= 100 &&
p[:Zimmer] == 2 &&
p[:Verfugbarkeit] >= 2 && p[:Verfugbarkeit] <= 8 &&
p[:Keller] == false && p[:Neubau] == true &&
p[:OV] == false
end
end
Benchmark.bm do |bm|
bm.report do
1.upto(100) { search }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment