Skip to content

Instantly share code, notes, and snippets.

@shingara
Created December 22, 2008 14:03
Show Gist options
  • Save shingara/38994 to your computer and use it in GitHub Desktop.
Save shingara/38994 to your computer and use it in GitHub Desktop.
Datamapper Benchmark
Benchmark with MySQL
shingara ~/data/perso/project/datamapper/dm-core $ ./script/performance.rb
Generating data for benchmarking...
Inserting 10,000 users...
Inserting 10,000 exhibits...
You can specify how many times you want to run the benchmarks with rake:perf x=(number)
Some tasks will be run 10 and 1000 times less than (number)
Benchmarks will now run 10000 times
| AR 2.1 | DM 0.9.8 | DIFF |
---------------------------------------------------------------------------------------
Model.new (instantiation) x10000 | 0.731 | 0.089 | 8.17x |
Model.new (setting attributes) x10000 | 2.762 | 1.752 | 1.58x |
Model.get specific (not cached) x10000 | 10.011 | 21.408 | 0.47x |
Model.get specific (cached) x10000 | 10.706 | 1.806 | 5.93x |
Model.first x10000 | 9.169 | 15.530 | 0.59x |
Model.all limit(100) x1000 | 26.779 | 46.560 | 0.58x |
Model.all limit(100) with relationship x1000 | 54.773 | 228.729 | 0.24x |
Model.all limit(10,000) x10 | 26.138 | 47.094 | 0.56x |
Model.create x10000 | 59.121 | 39.561 | 1.49x |
Resource#attributes x10000 | 5.133 | 3.481 | 1.47x |
Resource#update x10000 | 26.600 | 21.571 | 1.23x |
Resource#destroy x10000 | 34.813 | 41.619 | 0.84x |
Model.transaction x10000 | 5.553 | 9.361 | 0.59x |
=======================================================================================
Total | 272.289 | 478.562 | 1.83x |
With ActiveRecord 2.2.2
shingara@slick ~/data/perso/project/datamapper/dm-core $ ./script/performance.rb
/var/run/mysqld/mysqld.sock
which: no mysql5 in (/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.1.1:/usr/i686-pc-linux-gnu/gcc-bin/4.1.2:/opt/sun-jdk-1.4.2.19/bin:/opt/sun-jdk-1.4.2.19/jre/bin:/opt/sun-jdk-1.4.2.19/jre/javaws:/opt/sancho:/usr/kde/3.5/bin:/usr/qt/3/bin:/usr/games/bin:/home/shingara/bin)
which: no mysqldump5 in (/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.1.1:/usr/i686-pc-linux-gnu/gcc-bin/4.1.2:/opt/sun-jdk-1.4.2.19/bin:/opt/sun-jdk-1.4.2.19/jre/bin:/opt/sun-jdk-1.4.2.19/jre/javaws:/opt/sancho:/usr/kde/3.5/bin:/usr/qt/3/bin:/usr/games/bin:/home/shingara/bin)
Found data-file. Importing from ./script/../tmp/performance.sql
You can specify how many times you want to run the benchmarks with rake:perf x=(number)
Some tasks will be run 10 and 1000 times less than (number)
Benchmarks will now run 10000 times
| AR 2.2 | DM 0.9.8 | DIFF |
---------------------------------------------------------------------------------------
Model.new (instantiation) x10000 | 0.896 | 0.097 | 9.25x |
Model.new (setting attributes) x10000 | 3.056 | 1.903 | 1.61x |
Model.get specific (not cached) x10000 | 12.218 | 21.996 | 0.56x |
Model.get specific (cached) x10000 | 12.417 | 1.919 | 6.47x |
Model.first x10000 | 10.783 | 16.329 | 0.66x |
Model.all limit(100) x1000 | 28.005 | 48.874 | 0.57x |
Model.all limit(100) with relationship x1000 | 60.072 | 240.225 | 0.25x |
Model.all limit(10,000) x10 | 27.806 | 48.446 | 0.57x |
Model.create x10000 | 58.171 | 38.314 | 1.52x |
Resource#attributes x10000 | 4.858 | 3.861 | 1.26x |
Resource#update x10000 | 29.346 | 21.425 | 1.37x |
Resource#destroy x10000 | 37.516 | 41.511 | 0.90x |
Model.transaction x10000 | 6.632 | 9.232 | 0.72x |
=======================================================================================
Total | 291.776 | 494.131 | 1.98x |
Benchmark with postgreSQL
Spec test with Postgres database
| AR 2.2 | DM 0.9.8 | DIFF |
---------------------------------------------------------------------------------------
Model.new (instantiation) x10000 | 0.988 | 0.091 | 10.81x |
Model.new (setting attributes) x10000 | 3.182 | 1.897 | 1.68x |
Model.get specific (not cached) x10000 | 14.697 | 24.117 | 0.61x |
Model.get specific (cached) x10000 | 15.008 | 1.778 | 8.44x |
Model.first x10000 | 12.611 | 18.238 | 0.69x |
Model.all limit(100) x1000 | 36.629 | 49.251 | 0.74x |
Model.all limit(100) with relationship x1000 | 74.376 | 262.030 | 0.28x |
Model.all limit(10,000) x10 | 37.991 | 50.345 | 0.75x |
Model.create x10000 | 55.151 | 30.085 | 1.83x |
Resource#attributes x10000 | 5.372 | 3.780 | 1.42x |
Resource#update x10000 | 35.769 | 24.523 | 1.46x |
Resource#destroy x10000 | 74.410 | 32.860 | 2.26x |
Model.transaction x10000 | 7.064 | 11.304 | 0.62x |
=======================================================================================
Total | 373.248 | 510.298 | 2.43x |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment