Sha256: 019ef0bcc664dea5fbf606b5db58cd8d56bbfce1ee2db0f244772dd62d151550
Contents?: true
Size: 1.3 KB
Versions: 5
Compression:
Stored size: 1.3 KB
Contents
# # Simple Benchmarking Script. # # Meant to test performance for different types on connections under a typical # scenario of requesting multiple objects from the database in series. # # To run, use `bundle install` then: # # bundle exec ruby connections.rb # require 'rubygems' require 'bundler/setup' require 'benchmark' require 'couchrest_model' require 'faker' class SampleModel < CouchRest::Model::Base use_database "benchmark" property :name, String property :date, Date timestamps! design do view :by_name end end Benchmark.bm do |x| x.report("Create: ") do 100.times do |i| m = SampleModel.new( name: Faker::Name.name, date: Faker::Date.between(1.year.ago, Date.today) ) m.save! end end # Make sure the view is fresh SampleModel.by_name.limit(1).rows x.report("Fetch inc/docs:") do SampleModel.by_name.all.each do |doc| doc.to_json end end x.report("Fetch: ") do SampleModel.by_name.rows.each do |row| row.doc.to_json # Causes each doc to be fetched end end if CouchRest::Model::VERSION >= '2.1.0' x.report("Fetch w/block: ") do SampleModel.by_name.rows do |row| row.doc.to_json # Causes each doc to be fetched end end end end SampleModel.database.delete!
Version data entries
5 entries across 5 versions & 1 rubygems