Created
March 5, 2009 09:32
-
-
Save collin/74267 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'benchmark' | |
| require 'fileutils' | |
| require 'moneta' | |
| require 'moneta/rufus' | |
| require 'dm-core' | |
| FileUtils.rm_f 'benchmark.tch' | |
| cabinet = Moneta::Rufus.new(:file => 'benchmark') | |
| class Tweet | |
| include DataMapper::Resource | |
| property :id, Integer, :key => true | |
| property :data, Object | |
| end | |
| DataMapper.setup(:default, 'mysql://localhost/moneta_benchmark') | |
| DataMapper.auto_migrate! | |
| id = 1282653724 | |
| tweet = {"created_at"=>"Thu, 05 Mar 2009 09:13:49 +0000", "profile_image_url"=>"http://s3.amazonaws.com/twitter_production/profile_images/60834644/barack-obama2008_normal.jpg", "from_user"=>"TeamObama", "to_user_id"=>nil, "text"=>"Twitter post Obama targets waste in contract process - Baltimore Sun: Boston GlobeObama targets waste in .. http://tinyurl.com/bvvx2n", "id"=>1282653724, "from_user_id"=>2437269, "iso_language_code"=>"en", "source"=>"<a href="http://twitterfeed.com">twitterfeed</a>"} | |
| puts "Write" | |
| Benchmark.bm(5) do |x| | |
| x.report("Moneta::Rufus") do | |
| 10_000.times do |n| | |
| cabinet[n.to_s] = tweet | |
| end | |
| end | |
| x.report("DataMapper::MySql") do | |
| 10_000.times do |n| | |
| Tweet.create(:id => n, :data => tweet) | |
| end | |
| end | |
| end | |
| puts "Read" | |
| Benchmark.bm(5) do |x| | |
| x.report("Moneta::Rufus") do | |
| 10_000.times do |n| | |
| cabinet[n] | |
| end | |
| end | |
| x.report("DataMapper::MySql") do | |
| 10_000.times do |n| | |
| Tweet.get n | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Write | |
| user system total real | |
| Moneta::Rufus 0.490000 0.040000 0.530000 ( 0.550007) | |
| DataMapper::MySql 19.980000 2.760000 22.740000 (356.241752) | |
| Read | |
| user system total real | |
| Moneta::Rufus 0.980000 0.060000 1.040000 ( 1.078917) | |
| DataMapper::MySql 8.660000 1.200000 9.860000 ( 12.741560) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment