ORM Support

If you would like to add ORM support to your application, it’s simple. Out of the box Mack has support for two popular ORMs, ActiveRecord and DataMapper.Our tests show that DataMapper is 10x slower then ActiveRecord, but who knows, your mileage my vary.

When you create your mack app you can do the following which will add ORM support to your generated app:

$ mack my_cool_mack_app -o activerecord

If you already have a mack app you can very easily add ORM support by adding the following configuration parameter to the default.yml file:

mack::orm: activerecord

And also add a database.yml file to your config directory that looks like this:

development:
  adapter: mysql
  database: my_cool_mack_app_development
  host: localhost
  username: root
  password:

test:
  adapter: mysql
  database: my_cool_mack_app_test
  host: localhost
  username: root
  password:

production:
  adapter: mysql
  database: my_cool_mack_app_production
  host: localhost
  username: root
  password:

Tags: , ,

2 Responses to “ORM Support”

  1. Mr eel Says:

    I’m admittedly biased, but datamapper is 10x slower? That is certainly not my experience using the library.

    By and large DM is faster. AR still has an edge in some cases, but it’s definitely not 10x faster than DM.

    Wonky tests imo :)

  2. Mark Bates Says:

    I admit, I was very surprised as well. I’ve tried a bunch of different tests, doing different things, and they all came out the same.

    Here’s an example:

    These are from the console, MySQL, pulling back 1000 records:

    AR:
    running_time do
    Post.find(:all)
    end
    Running time 0.079149 seconds.

    DM:
    running_time do
    Post.find(:all)
    end
    Running time 0.856797 seconds.

    I’m not the only one who came to these conclusions:

    http://refactormycode.com/codes/240-datamapper-threaded-benchmark

    Notice the comment Sam Smoot left. Seems that there is a bug with 0.2.5 that makes it considerably slower.