Skip to content

Instantly share code, notes, and snippets.

@mharris717
Created April 25, 2014 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mharris717/11276545 to your computer and use it in GitHub Desktop.
Save mharris717/11276545 to your computer and use it in GitHub Desktop.
load "lib/baseball_lottery.rb"
MGC.connect! :production
def big_hash
res = {}
(1..100).each do |i|
res[i] = {}
50.times do
res[i][rand(100000000000)] = rand(1000000000000).to_s
end
end
res
end
class Payload
include Mongoid::Document
field :num, type: Integer
store_in session: "baseball_lottery"
end
class PayloadBig
include Mongoid::Document
field :nums, type: Hash
store_in session: "baseball_lottery"
end
Payload.delete_all
(1..5000).each_print_progress(name: "single number") do |i|
Payload.create! num: i
end
(1..500).each_print_progress(name: "big hash") do |i|
PayloadBig.create! nums: big_hash
end
str = <<EOF
local dev single: 1797/sec
big hash: 47/sec
num prod single: 53/sec
big prod: 0.9/sec
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment