Sha256: 6bcfe4aa972ee48e14bee0856664784bdb05e4e745c5f58886f9561e848152f8

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
$: << File.expand_path("../../lib", __FILE__)
require 'riak'
require 'benchmark'

http = Riak::Client.new(:http_backend => :Excon)
pbc = Riak::Client.new(:protocol => "pbc")

ops = {
  :list_buckets => [5],
  :list_keys => [20,"riakjs_http"],
  :ping => [100],
  :get_bucket_props => [1000,"riakjs_airlines"],
  :set_bucket_props => [100,"foo", {:n_val => 2}]
}

def textobj(c,key=nil)
  obj = c['bench'].new(key)
  obj.content_type = "text/plain"
  obj.raw_data = "This is a message to all out there who like to benchmark."
  obj  
end

KEYS = 1000

OPERATIONS = [
              [:ping,       lambda {|client| 100.times { client.ping }}],
              [:buckets,    lambda {|client| 10.times { client.buckets } }],
              [:get_bucket, lambda {|client| 1000.times { client.backend.get_bucket_props('foo') }}],
              [:set_bucket, lambda {|client| 100.times { client['foo'].props = {"n_val" => 2}}}],
              [:store_new,  lambda {|client| KEYS.times { textobj(client).store }}],
              [:store_key,  lambda {|client| KEYS.times {|i| textobj(client, "#{client.protocol}#{i}").store }}],
              [:fetch_key,  lambda {|client| KEYS.times {|i| client['bench'].get("#{client.protocol}#{i}") } }],
              [:keys,       lambda {|client| 5.times { client.backend.list_keys('bench') }}],
              [:key_stream, lambda {|client| 5.times { client['bench'].keys {|ks| "." }}}]
             ]

Benchmark.bmbm(25) do |x|
  OPERATIONS.each do |op|
    [http, pbc].each do |c|
      x.report("#{c.protocol.ljust(6)}#{op[0]}") do
        op[1][c]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
riak-client-0.9.5 pkg/httpvpbuf.rb