Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 20 lines (17 sloc) 0.657 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
require '../lib/chill'
require 'benchmark'
# A little benchmark to illustrate the performance difference between a bulk commit and individual commits
ChillDB.goes :BulkCommitBenchmark
Documents = 1000 # benchmark 1000 documents

puts "Bulk Commit of #{Documents}"
puts(bulk = Benchmark.realtime {
  BulkCommitBenchmark.commit! Documents.times.map { { random_number: rand(50) } }
})

puts "Single Commit of #{Documents}"
puts(single = Benchmark.realtime {
  Documents.times do
    { random_number: rand(50) }
    BulkCommitBenchmark.document( random_number: rand(50) ).commit!
  end
})

puts "Bulk Commit was #{ ((single / bulk) * 100).round(2) }% faster!"
Something went wrong with that request. Please try again.