Hi Roman I suggest as a first experiment, run the benchmarks with and without `timestamps :at` but with the additional properties. I suspect you are running into the fact that the DateTime class in ruby (used by the dm-timestamps plugin) is quite a heavy class to instantiate. But actually running the benchmark is the easiest way to determine this.
Regards Jon On 4 April 2011 15:58, Roman Catz <trusc...@gmail.com> wrote: > Hi all, > > Can anyone explain where is the bottlenecks in this examples: DM shows > slow results in comparing with AR > > AR: > %w( rubygems spec active_record benchmark).each{|lib| require lib} > > class StageItem < ActiveRecord::Base > validates_numericality_of :input, :output, :greater_than_or_equal_to > => 0 > validates_presence_of :user_id, :item_id, :x_coord, :y_coord > end > > class SoilItem < StageItem > end > > ActiveRecord::Base.establish_connection :adapter => "postgresql", > :database => "contry_development_3", :username => > "postgres", :password => "123", :host => "127.0.0.1", :port => 5432 > > describe StageItem do > it 'should create stageitem' do > SoilItem.connection.transaction do > n = 500 > Benchmark.bmbm do |x| > x.report {n.times { SoilItem.create(:user_id => 1, :item_id => > 1, :x_coord => 2, :y_coord => 4).should be_valid } } > end > end > end > end > > Simple example gives us following results: > Finished in 3.736249 seconds > > DM: > %w( rubygems spec dm-core dm-migrations dm-validations benchmark dm- > transactions dm-timestamps).each{|lib| require lib} > > class StageItem > include DataMapper::Resource > > property :id, Serial > property :user_id, Integer, :required => true > property :item_id, Integer, :required => true > > property :x_coord, Integer, :required => true > property :y_coord, Integer, :required => true > > property :type, Discriminator > end > > class SoilItem < StageItem > end > > DataMapper.setup(:default, :adapter=>"postgres", :user=>"postgres", > :password=>"123", :host > => "localhost", :path=>"/contry_development_3") > > describe StageItem do > it 'should create stageitem' do > StageItem.transaction do > n = 500 > Benchmark.bmbm do |x| > x.report {n.times { SoilItem.create(:user_id => 1, :item_id => > 1, :x_coord => 2, :y_coord => 4).should be_valid } } > end > end > end > end > > Simple example gives us following results: > Finished in 2.646424 seconds > > Not bad. > > I've added several properties and timestamps > property :input, Integer, :required => true, :default => 0 > property :output, Integer, :required => true, :default => 0 > > property :extra_input, String, :required => false > property :extra_output, String, :required => false > property :extra1, Integer > > timestamps :at > > Results now is following: > Finished in 5.370599 seconds > > Why the time is increased so much? How should I improve it? > > Great thanks, Roman > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To post to this group, send email to datamapper@googlegroups.com. > To unsubscribe from this group, send email to > datamapper+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/datamapper?hl=en. > > -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to datamapper@googlegroups.com. To unsubscribe from this group, send email to datamapper+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.