Sha256: 17209642d7c9735e7736ca0f7436868a05262487ed1097760bc758ae736199d5

Contents?: true

Size: 1.44 KB

Versions: 61

Compression:

Stored size: 1.44 KB

Contents

# The purpose of this is to check finding, initializing, 
# and creating objects (typecasting times/dates and booleans).

require 'pp'
require 'benchmark'
require 'rubygems'

# to test with slow version just do this:
# gem 'mongo_mapper', '0.6.10'
# and comment out this:
$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'mongo_mapper'

MongoMapper.database = 'testing'
 
class Foo
  include MongoMapper::Document
  key :approved, Boolean
  key :count, Integer
  key :approved_at, Time
  key :expire_on, Date
  timestamps!
end
Foo.collection.remove

Benchmark.bm(5) do |x|
  ids = []
  x.report("write") do
    1000.times { |i| ids << Foo.create(:count => 0, :approved => true, :approved_at => Time.now, :expire_on => Date.today).id }
  end

  x.report("read ") do
    ids.each { |id| Foo.first(:id => id) }
  end
end

# I was get something like this on my puny macbook air:
#            user     system      total        real
# write  4.810000   0.090000   4.900000 (  5.039949)
# read   2.730000   0.070000   2.800000 (  2.990749)
#
#
# After these commits:
#
#   * http://github.com/jnunemaker/mongomapper/commit/e5091fa140d5fae2721017b53027092233694ee5
#   * http://github.com/jnunemaker/mongomapper/commit/c22bbde4fa1cfbc310d79cb0e50203310ffb03d1
#
# I'm now getting something like this:
#            user     system      total        real
# write  1.660000   0.050000   1.710000 (  1.752676)
# read   1.060000   0.050000   1.110000 (  1.263429)

Version data entries

61 entries across 61 versions & 9 rubygems

Version Path
pwnash-mongo_mapper-0.7.5 performance/read_write.rb
mongo_mapper-0.7.5 performance/read_write.rb
mongo_mapper_ign-0.7.4 performance/read_write.rb
mongo_mapper-0.7.4 performance/read_write.rb
mongo_mapper-0.7.3 performance/read_write.rb
numon-0.0.1 performance/read_write.rb
mongo_mapper-0.7.2 performance/read_write.rb
mongo_mapper-0.7.1 performance/read_write.rb
mongo_mapper-unstable-2010.3.8 performance/read_write.rb
mongo_mapper-unstable-2010.3.5 performance/read_write.rb
mongo_mapper-unstable-2010.3.4 performance/read_write.rb
mongo_mapper-unstable-2010.3.3 performance/read_write.rb
drogus-mongo_mapper-0.6.10 performance/read_write.rb
mongo_mapper-rails3-0.7.0.1 performance/read_write.rb
mongo_mapper-unstable-2010.2.28 performance/read_write.rb
mongo_mapper-unstable-2010.2.27 performance/read_write.rb
mongo_mapper-unstable-2010.2.26 performance/read_write.rb
mongo_mapper-unstable-2010.2.25 performance/read_write.rb
mongo_mapper-unstable-2010.2.24 performance/read_write.rb
mongo_mapper-unstable-2010.2.23 performance/read_write.rb