Created
February 9, 2012 15:31
-
-
Save sreeix/1780684 to your computer and use it in GitHub Desktop.
cassandra benchmarking code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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