Skip to content

Instantly share code, notes, and snippets.

@gigq
Created August 12, 2009 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gigq/166802 to your computer and use it in GitHub Desktop.
Save gigq/166802 to your computer and use it in GitHub Desktop.
couchload.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'couchrest'
require 'uuidtools'
require 'benchmark'
couch = CouchRest.new("http://localhost:5984")
db = couch.database('couchload')
db.delete! rescue nil
db = couch.create_db('couchload')
results = File.new("/tmp/couchload.csv", "w")
(1..10000).each do |batch|
array = []
results.puts batch.to_s+"\t"+Benchmark.realtime {
(1..1000).each do |row|
array << {"_id" => UUIDTools::UUID.random_create.to_i.to_s(36), "batch" => batch, "row" => row }
end
db.bulk_save(array)
}.to_s
results.flush
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment