Did you run the AR test right after running the DM test? MySQL query cache could possibly play a role, though I doubt to such an extent on such a simple query.
I'm not familiar with how the benchmark tool works... I assume it only loads the environment once and then performs the entire test starting from the point that the whole environment is loaded (i.e. the initialization overhead isn't something that would affect it?). In reality, it's unlikely that this would have much of an effect (for 95% of the internet) in production and that schema optimization and caching would come before ruby code optimization, but it's interesting nonetheless. El 16/05/2011, a las 22:13, mileszs escribió: > I recently gave a presentation at the Indianapolis Ruby Brigade > monthly meeting, covering aspects of DM I like, and recommending the > crowd give it a shot in their next project. I was asked about > performance, as I knew I would be, but I hadn't really taken a good > run at a performance comparison at the time (which seems like a huge > failure on my part, considering I've put a Rails 3 DM app in to > production). Thus, I sat down yesterday intending to get some numbers > I could show people. Unfortunately, the results were surprisingly > negative for DataMapper. I am hoping that I'm unwittingly performing a > poor benchmark. > > You can get the code I used here: > https://github.com/mileszs/dm-v-ar-performance > > In both apps there is a very basic User model. They are using the same > database (on MySQL). The db/seeds.rb file in the DataMapper app > creates 10000 user records. > > I used the recommended app template to generate the DataMapper app: > > rails new dm-perf-app -m http://datamapper.org/templates/rails.rb > bundle install > rails g scaffold User email:string > rake db:setup > rake db:seed > > > The ActiveRecord app is similar, but uses the same database: > > rails new ar-perf-app > bundle install > rails g scaffold User email:string > > > To test performance, I used variations of: > > # DataMapper > env RAILS_ENV=production rails benchmarker "10000.times { |i| u = > User.all(:id => i).first; u.email if u }" > > # ActiveRecord > env RAILS_ENV=production rails benchmarker "10000.times { |i| u = > User.where(:id => i).first; u.email if u }" > > > ... which I stole from Luke Ludwig's "Rails 3 Performance - Not Good > Enough article. > > Results: > > DataMapper: > user system total real > #1 10.530000 0.630000 11.160000 ( 12.580429) > > ActiveRecord: > user system total real > #1 3.150000 0.300000 3.450000 ( 4.171568) > > (I have run the test several times with similar results.) Are there > obvious errors in my method? Perhaps some basic things I could do to > improve performance? I really like DataMapper, so it will be > disappointing to report back such a discrepancy in performance. > > Thank you for any help you can provide! > > MilesZS > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.
