Skip to content

Instantly share code, notes, and snippets.

@AtnNn
Created January 30, 2014 16:50
Show Gist options
  • Select an option

  • Save AtnNn/8713050 to your computer and use it in GitHub Desktop.

Select an option

Save AtnNn/8713050 to your computer and use it in GitHub Desktop.
require 'rethinkdb'
include RethinkDB::Shortcuts
doc = {
:archived_date => nil,
:archived_parent_task_guid => nil,
:archived_tree_guid => nil,
:archived_tree_path => "",
:assigned_to_guid => "d0b93cc0-1a4b-4513-98a8-daccb341df23",
:change_date => "2012-06-27T10:04:50Z",
:completion_date => nil,
:context_guid => nil,
:creation_date => "2012-06-19T12:13:17Z",
:done => false,
:due_date => "2014-01-28T23:00:00Z",
:expanded => true,
:hide_until_date => nil,
:manual_sort => false,
:name => "Go through last few quarterly reports to see how they've been done in the past",
:next_sibling_guid => "1351c07c-1780-49f9-a2a7-a1b16fa490aa",
:notes_docx => nil,
:notes_selection_start => 0,
:parent_task_guid => nil,
:percent_done => 0,
:priority_guid => "fe8c366e-60b4-4eeb-a396-55ddc1157208",
:start_date => nil,
:status_guid => "9579ded2-0939-4acd-b158-4551fe70125c",
:stickynote_always_on_top => false,
:stickynote_color => -1,
:stickynote_enabled => false,
:stickynote_position_x_shared => -1,
:stickynote_position_y_shared => -1,
:stickynote_show_task_notes => true,
:stickynote_size_height => -1,
:stickynote_size_width => -1,
:stickynote_transparency => 10,
:time_estimate => 0,
:time_spent => 0,
:tree_guid => "3ab17474-02d2-4394-b7fd-9aedbadd04d6",
:type_guid => nil
}
$c = r.connect(:host => 'localhost', :port => 28018).repl
def reset_table
begin
r.table_drop('test_1920').run
rescue
ensure
r.table_create('test_1920').run
end
end
tbl = r.table('test_1920')
def timeit(name, &b)
start = Time.now
b.call
end_ = Time.now
dur = (end_ - start)
puts "#{name}: #{dur}s"
end
total = 5000
[5000,1000,100,10,1].each do |batch_size|
['hard', 'soft'].each do |durability|
reset_table
batch = [doc] * batch_size
timeit "Insert #{total}, #{batch_size} at a time, #{durability} durability" do
(1..(5000 / batch_size)).each do
tbl.insert(batch, :durability => durability).run
end
end
count = tbl.count.run
raise "Bad count: #{count}" unless count == total
end
end
@AtnNn

AtnNn commented Jan 30, 2014

Copy link
Copy Markdown
Author
Insert 5000, 5000 at a time, hard durability: 1.952049377s
Insert 5000, 5000 at a time, soft durability: 1.220283407s
Insert 5000, 1000 at a time, hard durability: 1.522391758s
Insert 5000, 1000 at a time, soft durability: 1.180190628s
Insert 5000, 100 at a time, hard durability: 2.599218936s
Insert 5000, 100 at a time, soft durability: 2.07323062s
Insert 5000, 10 at a time, hard durability: 24.948930017s
Insert 5000, 10 at a time, soft durability: 23.040669284s
Insert 5000, 1 at a time, hard durability: 30.39618428s
Insert 5000, 1 at a time, soft durability: 22.163877565s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment