Skip to content

Instantly share code, notes, and snippets.

@solnic
Forked from syrnick/gist:767201
Created February 2, 2011 09:31
Show Gist options
  • Save solnic/807464 to your computer and use it in GitHub Desktop.
Save solnic/807464 to your computer and use it in GitHub Desktop.
require 'rubygems'
gem 'dm-core', '0.10.2'
gem 'dm-migrations', '0.10.2'
gem 'dm-timestamps', '0.10.2'
require 'dm-core'
require 'dm-migrations'
require 'dm-timestamps'
require 'dm-migrations/migration_runner'
require 'benchmark'
DataMapper.setup(:default, 'sqlite3::memory') # createdb test
class Course
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :exams
end
class Exam
include DataMapper::Resource
property :id, Serial
belongs_to :course
end
#DataMapper.finalize
DataMapper.auto_migrate!
Benchmark.bm do |x|
x.report do
1000.times do |i|
course = Course.create(:name =>"Ruby #{i}")
Exam.create(:course => course)
end
end
end
DM 0.10.2:
user system total real
4.250000 1.130000 5.380000 ( 36.003685)
DM master (02/02/2011):
user system total real
6.850000 1.150000 8.000000 ( 36.257449)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment