Skip to content

Commit

Permalink
headslap. am in Ruby.
Browse files Browse the repository at this point in the history
  • Loading branch information
benzenwen committed Mar 25, 2012
1 parent d0041b1 commit 167feb6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions writer.rb
Expand Up @@ -79,12 +79,18 @@
{'messagetype' => 'complex', 'ordinal' =>0, 'subdocument' => {'fname' => 'George', 'lname' => 'Washington', 'subproperty' => 'US-president'}}]

# Run until killed
i = 0
i = 1
while(true)
doc = docs[rand(3)].dup # MongoDB collection.insert mutates document, editing the _id key; we need a deep dup (copy).
doc['time'] = Time.now().to_f * 1000 # Switch to Javascript's convention
doc['ordinal'] = i++
doc['ordinal'] = i
print i
coll.insert(doc, :safe => true)
debug ? pp(doc) : puts("Inserting #{doc['messagetype']} message")
sleep(rate)
if i == 2**30 -1 then # Not like we'll ever hit this at 1/sec, but someone could crank up the speed.
i = 1 else
i = i + 1
end

end

0 comments on commit 167feb6

Please sign in to comment.