Skip to content

Instantly share code, notes, and snippets.

@rhenning
Created July 22, 2015 17:44
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 rhenning/b54f12514ca4bbabf65a to your computer and use it in GitHub Desktop.
Save rhenning/b54f12514ca4bbabf65a to your computer and use it in GitHub Desktop.
Mongo embedded array push test
require 'moped'
require 'benchmark'
s = Moped::Session.new(%w(127.0.0.1:27017))
s.use 'junkdb'
s.drop
s[:test].insert(foo: [])
Benchmark.bm do |b|
10000.times do |i|
b.report(i) do
s[:test].find.update(:$push => { foo: { i => rand } } )
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment