Skip to content

Instantly share code, notes, and snippets.

@banks
Last active January 29, 2016 21:48
Show Gist options
  • Save banks/c046d7eb9425f57de1e9 to your computer and use it in GitHub Desktop.
Save banks/c046d7eb9425f57de1e9 to your computer and use it in GitHub Desktop.
// On Macbook pro quad-core 2014 retina 15inch
Opts: {}
Batches of 1
Inserting 5000 docs took 52808.177948ms @ 94.6822834187 per second
Batches of 10
Inserting 5000 docs took 9779.50787544ms @ 511.27290901 per second
Batches of 200
Inserting 5000 docs took 1662.64986992ms @ 3007.23692097 per second
Opts: {'durability': 'soft'}
Batches of 1
Inserting 5000 docs took 2748.38781357ms @ 1819.23509528 per second
Batches of 10
Inserting 5000 docs took 893.51606369ms @ 5595.84640582 per second
Batches of 200
Inserting 5000 docs took 492.085933685ms @ 10160.7235345 per second
Opts: {'noreply': True}
Batches of 1
Inserting 5000 docs took 665.778875351ms @ 7509.93104757 per second
Batches of 10
Inserting 5000 docs took 325.963973999ms @ 15338.837946 per second
Batches of 200
Inserting 5000 docs took 310.087203979ms @ 16124.236038 per second
Opts: {'noreply': True, 'durability': 'soft'}
Batches of 1
Inserting 5000 docs took 1031.69989586ms @ 4846.35151874 per second
Batches of 10
Inserting 5000 docs took 396.315813065ms @ 12616.0720839 per second
Batches of 200
Inserting 5000 docs took 244.823932648ms @ 20422.4223308 per second
import rethinkdb as r
import time
conn = r.connect('localhost', 28015)
conn.use('test')
total_to_send = 5000
for opts in [{}, {"durability": "soft"}, {"noreply": True}, {"durability": "soft", "noreply": True}]:
print "Opts: ", opts
for n in [1, 10, 200]:
print " Batches of ", n
start = time.time()
for i in xrange(0, total_to_send, n):
docs = [{"foo": "bar", "i":i, "x":x} for x in xrange(0, n)]
r.table('foo').insert(docs).run(conn, **opts)
print " Inserting "+str(total_to_send)+" docs took "+str((time.time() - start) * 1000)+"ms @ "+str(total_to_send/(time.time() - start))+" per second"
# Sleep to give noreply tests a chance for DB to catch up with all the stuff we just threw at it
if "noreply" in opts:
time.sleep(20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment