Skip to content

Instantly share code, notes, and snippets.

@collin
Created March 5, 2009 10:48
Show Gist options
  • Select an option

  • Save collin/74292 to your computer and use it in GitHub Desktop.

Select an option

Save collin/74292 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'benchmark'
require 'fileutils'
require 'moneta'
require 'moneta/rufus'
FileUtils.rm_f 'benchmark.tch'
cabinet = Moneta::Rufus.new(:file => 'benchmark')
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
500_000.times do |n|
cabinet[n.to_s] = tweet
end
end
end
puts "Read"
Benchmark.bm(5) do |x|
x.report("Moneta::Rufus") do
200_000.times do |n|
cabinet[n]
end
end
end
Write
user system total real
Moneta::Rufus 23.850000 5.520000 29.370000 ( 50.425661)
Read
user system total real
Moneta::Rufus 15.930000 1.300000 17.230000 ( 17.769838)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment