38 lines
715 B
Ruby
Executable File
38 lines
715 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|
|
|
cursor = c.find({:id => i})
|
|
x = cursor.next_object
|
|
cursor.close
|
|
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
|