Permalink
Browse files

simple benchmark

  • Loading branch information...
1 parent aa1a866 commit e1d4583d51e054f8207e545bb46029eaed3d79f9 @freels committed Aug 24, 2010
Showing with 32 additions and 0 deletions.
  1. +6 −0 Rakefile
  2. +26 −0 spec/kestrel_benchmark.rb
View
@@ -12,6 +12,12 @@ Spec::Rake::SpecTask.new(:spec) do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
end
+desc "Run benchmarks"
+Spec::Rake::SpecTask.new(:benchmark) do |t|
+ t.spec_opts = ['--options', "\"#{ROOT_DIR}/spec/spec.opts\""]
+ t.spec_files = [File.expand_path('spec/kestrel_benchmark.rb')]
+end
+
# gemification with jeweler
begin
require 'jeweler'
View
@@ -0,0 +1,26 @@
+require 'spec/spec_helper'
+require 'benchmark'
+
+describe Kestrel::Client do
+ before do
+ @queue = "a_queue"
+ @kestrel = Kestrel::Client.new(*Kestrel::Config.default)
+
+ @kestrel.delete(@queue) rescue nil # Memcache::ServerEnd bug
+ end
+
+ it "is fast" do
+ @kestrel.flush(@queue)
+ @value = { :value => "a value" }
+ @raw_value = Marshal.dump(@value)
+
+ times = 10_000
+
+ Benchmark.bm do |x|
+ x.report("set:") { for i in 1..times; @kestrel.set(@queue, @value); end }
+ x.report("get:") { for i in 1..times; @kestrel.get(@queue); end }
+ x.report("set (raw):") { for i in 1..times; @kestrel.set(@queue, @raw_value, 0, true); end }
+ x.report("get (raw):") { for i in 1..times; @kestrel.get(@queue, true); end }
+ end
+ end
+end

0 comments on commit e1d4583

Please sign in to comment.