I recently had an opportunity to do a little presentation and I chose to talk about replacing the ActiveRecord ORM (Object Relational Mapper) with DataMapper in a Ruby on Rails application. DataMapper was incredibly fast at returning records. For a single table look up, it took 0.0150% of the time that ActiveRecord took to return all 10,000 records. Holy Toledo!
Here, check this out. This is a series of benchmark runs between two nearly identical applications. They both have the exact structure, number of pages, etc. and same number of pages. But, one application is using ActiveRecord and the other is using DataMapper.
10,000 Records recalled with ActiveRecord
10,000 Records recalled with DataMapper
Datamapper requires 0.0150% as much time as ActiveRecord
One cool thing about doing this presentation is that when I started encountering problems with working on Rails in XP (although I know it is possible for the most part), I decided to create a Linux installation. My first thought was to repartion my hard drive and install Linux there. But, I'm using an older machine and was afraid of data loss (fortunately, I use an online backup solution for recoverability, but there is still all that work to do). Therefore, I ended up creating a persistable Ubuntu 8.10 installation on a 2 GB Flash Drive. That will have to be a topic for another post.
The presentation is available on SlideShare for your viewing pleasure. I walk through the steps in the presentation after a very quick overview of ActiveRecord and DataMapper. The source is available on github.
Please use the SlideShare posting and the github source for your resources. I used the DataMapper web site, of course, as a primary reference. I also used
François Beausoleil's blog, How to Use DataMapper From Rails, Including Migrations and Tests, to get started.