2009-02-05 19:24:59 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
LONG_STRING = "lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas" * 6
|
|
|
|
|
|
|
|
require File.join(File.dirname(__FILE__), '_common.rb')
|
|
|
|
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
|
|
|
c = db.collection('stress1')
|
|
|
|
|
2009-02-05 21:00:45 +00:00
|
|
|
n1 = 50_000
|
|
|
|
n2 = 10_000
|
|
|
|
|
|
|
|
if $DEBUG
|
|
|
|
n1 = 5
|
|
|
|
n2 = 1
|
2009-02-05 19:47:33 +00:00
|
|
|
c.drop
|
|
|
|
end
|
|
|
|
|
2009-02-05 21:00:45 +00:00
|
|
|
n1.times { |i|
|
|
|
|
c.insert(:name => "asdf#{i}", :date => Time.now, :id => i,
|
2009-02-05 19:24:59 +00:00
|
|
|
:blah => LONG_STRING, :subarray => [])
|
|
|
|
}
|
|
|
|
puts
|
|
|
|
|
2009-02-05 21:00:45 +00:00
|
|
|
n2.times { |i|
|
2009-08-14 19:39:49 +00:00
|
|
|
x = c.find_one({:id => i})
|
2009-02-05 19:24:59 +00:00
|
|
|
x['subarray'] = "foo#{i}"
|
2009-02-05 21:00:45 +00:00
|
|
|
p x
|
|
|
|
c.modify({:id => i}, x)
|
2009-02-05 19:24:59 +00:00
|
|
|
}
|
|
|
|
puts
|
2009-02-05 21:00:45 +00:00
|
|
|
|
|
|
|
if $DEBUG
|
|
|
|
puts "stress1 has #{c.count} records"
|
|
|
|
c.find.each { |row| puts "#{row['id']}: #{row['subarray'].inspect}" }
|
|
|
|
end
|