mongo-ruby-driver/test/mongo-qa/stress1
2009-08-18 10:07:01 -04:00

36 lines
674 B
Ruby
Executable File

#!/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')
n1 = 50_000
n2 = 10_000
if $DEBUG
n1 = 5
n2 = 1
c.drop
end
n1.times { |i|
c.insert(:name => "asdf#{i}", :date => Time.now, :id => i,
:blah => LONG_STRING, :subarray => [])
}
puts
n2.times { |i|
x = c.find_one({:id => i})
x['subarray'] = "foo#{i}"
p x
c.modify({:id => i}, x)
}
puts
if $DEBUG
puts "stress1 has #{c.count} records"
c.find.each { |row| puts "#{row['id']}: #{row['subarray'].inspect}" }
end