Skip to content

Instantly share code, notes, and snippets.

@sreeix
Created February 9, 2012 15:31
Show Gist options
  • Select an option

  • Save sreeix/1780684 to your computer and use it in GitHub Desktop.

Select an option

Save sreeix/1780684 to your computer and use it in GitHub Desktop.
cassandra benchmarking code
require 'benchmark'
require 'cassandra/0.7'
@client = Cassandra.new('Search', '127.0.0.1:9160')
@json = JSON.parse(File.read("coupon.json"))
@index = 0
def create_coupon
@index += 1
@client.insert(:Coupon, @index.to_s, @json)
end
100.times do |i|
puts "50000 Docs: #{i}"
time = Benchmark.measure{ 50000.times{create_coupon} }
puts time
av_time = time.real / 50000.to_f
puts "Average time = #{av_time}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment