bastos (owner)

Revisions

gist: 127946 Download_button fork
public
Public Clone URL: git://gist.github.com/127946.git
Embed All Files: show embed
benchmemcachedruby1819.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/ruby
 
require 'rubygems'
require 'memcache'
require 'benchmark'
 
MEMCACHE_OPTIONS = {
  :c_threshold => 10_000,
  :compression => true,
  :debug => false,
  :namespace => "bench:",
  :readonly => false,
  :urlencode => false,
  :multithread => true
}
 
CACHE = MemCache.new ['0.0.0.0:11211'], MEMCACHE_OPTIONS
 
Benchmark.bm do |b|
  b.report("Memcached access") do
    10000.times do
      CACHE.set "#{rand(1000)}-#{rand(1000)}-#{rand(1000)}", "010010" * rand(1000)
    end
  end
end