Created
May 28, 2012 13:48
-
-
Save jonelf/2819303 to your computer and use it in GitHub Desktop.
Ruby implementation of http://stackoverflow.com/questions/10784303/v8-like-hashtable-for-c
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' | |
@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