Created
June 13, 2013 22:36
-
-
Save rb2k/5777997 to your computer and use it in GitHub Desktop.
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 "rubygems" | |
require 'rethinkdb' | |
require 'oj' | |
require 'multi_json' | |
include RethinkDB::Shortcuts | |
r.connect({:db => 'testing'}).repl | |
r.db_drop('test_db').run rescue nil | |
r.db_create('test_db').run | |
r.db('test_db').table_create('data', {:durability => 'soft'}).run | |
table = r.db('test_db').table('data') | |
insertion_cache = [] | |
i = 0 | |
start = Time.now | |
loop do | |
i+=1 | |
to_insert = {} | |
10.times {|i| to_insert["key#{i}"] = rand(33333).to_s * rand(6) } | |
insertion_cache << to_insert | |
begin | |
if (i) % 100 == 0 | |
duration_so_far = Time.now - start | |
puts "#{i}\t\t#{to_insert[:id]} (#{(i.to_f / duration_so_far).to_i} inserts/sec)" | |
table.insert(insertion_cache).run | |
insertion_cache = [] | |
end | |
rescue => e | |
puts e.message | |
puts to_insert.inspect | |
sleep 10 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment