Last active
January 21, 2017 00:03
-
-
Save jots/57435b395e189d9dfbc33c522b38e630 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
# results: | |
# doing 100000000 records | |
# set: 24.3293866 -- ( 4110255 per second) | |
# `ps -p #{Process.pid} -o rss` # => " RSS\n9547028\n" | |
# 99999999 | |
# get: 0.4833987 -- ( 206868574 per second ) | |
a = {} of Int32 => String | |
num = 100_000_000 | |
puts "doing #{num} records" | |
start = Time.now | |
1.upto(num) do |x| | |
a[x] = x.to_s | |
end | |
diff = (Time.now - start).total_seconds | |
puts "set: #{diff} -- ( #{(num/diff).to_i} per second)" | |
# how much memory we using | |
pp `ps -p #{Process.pid} -o rss` | |
start = Time.now | |
match = num - 1 | |
1.upto(num) do |x| | |
b = a[x] | |
# put second to last one just to make sure... | |
if x == match | |
puts b | |
end | |
end | |
diff = (Time.now - start).total_seconds | |
puts "get: #{diff} -- ( #{(num/diff).to_i} per second )" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment