Created
August 12, 2009 21:54
-
-
Save gigq/166802 to your computer and use it in GitHub Desktop.
couchload.rb
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
#!/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