-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample9_rocking_chair_performance.rb
54 lines (43 loc) · 1.21 KB
/
example9_rocking_chair_performance.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'rubygems'
require 'simply_stored/couch'
require 'rocking_chair'
require "benchmark"
require "helper"
class User
include SimplyStored::Couch
property :login
property :email
property :accepted_terms_of_service, :type => :boolean
property :last_login, :type => Time
has_many :posts
end
COUNT = 100
User.find_by_login(""); puts "\n\n\n"
Benchmark.bm(7) do |x|
x.report("Talking to CouchDB") do
count = COUNT
now = Time.now
count.times do |i|
User.create!(:login => "user #{i}", :email => "user#{i}@example.com", :accepted_terms_of_service => true, :last_login => now)
print '.'; $stdout.flush
end
count.times do |i|
User.find_by_login("user #{i}")
print '.'; $stdout.flush
end
end
RockingChair.enable
CouchPotato.couchrest_database.server.create_db('rugb')
x.report("Talking to RockingChair") do
count = COUNT
now = Time.now
count.times do |i|
User.create!(:login => "user #{i}", :email => "user#{i}@example.com", :accepted_terms_of_service => true, :last_login => now)
print '.'; $stdout.flush
end
count.times do |i|
User.find_by_login("user #{i}")
print '.'; $stdout.flush
end
end
end