roadrunner 4.0.3 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/lib/report.rb +2 -2
- data/lib/roadrunner.rb +5 -4
- data/lib/rrmonitor.rb +3 -3
- data/lib/run.rb +60 -14
- data/log/stdout.log +151 -4
- data/log/stdout.log.20100422 +4 -0
- data/test/pi.rb +34 -0
- data/test/prime_p.rb +6 -7
- data/test/vbd_kv.rb +97 -25
- metadata +3 -2
data/Rakefile
CHANGED
data/lib/report.rb
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
|
4
4
|
module RoadRunnerModule
|
5
5
|
|
6
|
-
def report(label
|
6
|
+
def report(opts={:label=>'',:width=>0,:msg=>""})
|
7
7
|
p " Wait for moment,the report is collecting......"
|
8
8
|
content = if @rep
|
9
9
|
@succRates = getSuccessRate @transactions
|
10
10
|
<<-DOC
|
11
11
|
#{"Performance Reports".center(50, '*')}
|
12
|
-
#{label.ljust(width)}
|
12
|
+
#{opts[:label].ljust(opts[:width])}
|
13
13
|
#{Benchmark::Tms::CAPTION}
|
14
14
|
#{@rep.format}
|
15
15
|
#{'--'*32}
|
data/lib/roadrunner.rb
CHANGED
@@ -15,14 +15,14 @@ Dir[File.join(File.dirname(__FILE__),"*.rb")].select{|x|not (x =~ /.*model\.rb/
|
|
15
15
|
class RoadRunner
|
16
16
|
|
17
17
|
include RoadRunnerModule
|
18
|
-
attr :iterations,
|
18
|
+
attr :iterations,true
|
19
19
|
attr :users,true
|
20
20
|
attr :global,true
|
21
21
|
attr :iterationId
|
22
22
|
attr :record
|
23
23
|
attr :userId
|
24
24
|
attr :mode,true
|
25
|
-
attr :log
|
25
|
+
attr :log,true
|
26
26
|
attr :tps
|
27
27
|
alias_method :g,:global
|
28
28
|
alias_method :g=,:global=
|
@@ -35,6 +35,7 @@ class RoadRunner
|
|
35
35
|
@global,@transactions={},{}
|
36
36
|
@log=Logger.new(opts[:out],opts[:frequency],opts[:size])
|
37
37
|
@log.level=opts[:level]
|
38
|
+
@log.info("#{'-'*20} #{$0} RoadRunner log #{'-'*20}")
|
38
39
|
# => mode : sequence<default>,thread|t,process|p
|
39
40
|
@mode='sequence'
|
40
41
|
|
@@ -103,10 +104,10 @@ class RoadRunner
|
|
103
104
|
else status = 0
|
104
105
|
end
|
105
106
|
# {:stats=>status,:cost=>rcost,:create_at=>Time.now} is one record
|
106
|
-
@transactions[name] << {:stats=>status,:cost=>rcost,:create_at=>Time.now}
|
107
|
+
@transactions[name] << {:stats=>status,:cost=>rcost,:create_at=>Time.now.to_s}
|
107
108
|
# => the below sentence cost a lot of system resource
|
108
109
|
# => if you run for production result,keep it annotated!!!
|
109
|
-
#
|
110
|
+
# self.log.debug "#{name} => "+@transactions[name].inspect
|
110
111
|
rcost
|
111
112
|
end
|
112
113
|
|
data/lib/rrmonitor.rb
CHANGED
@@ -121,14 +121,14 @@ class RRMonitor
|
|
121
121
|
@log.info("Monitor STOP!".center(60,"*"))
|
122
122
|
end
|
123
123
|
|
124
|
-
def collect
|
124
|
+
def collect(username)
|
125
125
|
@log.debug "mkdir -p #{@path}/#{@server}"
|
126
126
|
%x{mkdir -p #{@path}/#{@server}}
|
127
127
|
|
128
128
|
path = @path.gsub('~',`echo ~`.gsub(/[\r\n]/,''))
|
129
129
|
@log.info "Collecting...".center(60,"*")
|
130
130
|
@log.debug "collect path => #{path}/#{@server}"
|
131
|
-
`scp -r
|
131
|
+
`scp -r #{username}@#{@server}:#{@rpath} #{path}/#{@server}`
|
132
132
|
@log.info "collected files => #{Dir[path+'/'+@server+'/**/*'].join($/)}"
|
133
133
|
end
|
134
134
|
|
@@ -162,7 +162,7 @@ class RRMonitor
|
|
162
162
|
|
163
163
|
_servers.each do |k,v|
|
164
164
|
v.stop!
|
165
|
-
v.collect
|
165
|
+
v.collect(servers[:username])
|
166
166
|
end
|
167
167
|
|
168
168
|
end
|
data/lib/run.rb
CHANGED
@@ -9,6 +9,24 @@ module RoadRunnerModule
|
|
9
9
|
@counter = 0
|
10
10
|
|
11
11
|
@log.debug "Mode => #{@mode}"
|
12
|
+
|
13
|
+
# >> Benchmark.bm {|x|x.report{(1..10).to_a.max}}
|
14
|
+
# user system total real
|
15
|
+
# 0.000000 0.000000 0.000000 ( 0.000034)
|
16
|
+
# => true
|
17
|
+
# >> Benchmark.bm {|x|x.report{(1..100).to_a.max}}
|
18
|
+
# user system total real
|
19
|
+
# 0.000000 0.000000 0.000000 ( 0.000214)
|
20
|
+
# => true
|
21
|
+
# >> Benchmark.bm {|x|x.report{(1..1000).to_a.max}}
|
22
|
+
# user system total real
|
23
|
+
# 0.000000 0.000000 0.000000 ( 0.002074)
|
24
|
+
# => true
|
25
|
+
# >> Benchmark.bm {|x|x.report{(1..1000000).to_a.max}}
|
26
|
+
# user system total real
|
27
|
+
# 1.030000 0.670000 1.700000 ( 1.766415)
|
28
|
+
# => true
|
29
|
+
|
12
30
|
iterationBlk = case @mode
|
13
31
|
when /thread/,/t/ then
|
14
32
|
proc {
|
@@ -16,20 +34,20 @@ module RoadRunnerModule
|
|
16
34
|
@thread_pool[Thread.start(){
|
17
35
|
@iterations.times do |iterationId|
|
18
36
|
|
19
|
-
rcost =
|
37
|
+
rcost = []
|
20
38
|
@transaction_blk.each_pair{|k,v|
|
21
|
-
rcost
|
39
|
+
rcost << self.transaction(k,&v)
|
22
40
|
}
|
23
41
|
|
24
42
|
# rcost = self.transaction('Action',&@actBlk)
|
25
|
-
|
26
|
-
@longest = (@longest<rcost)?rcost
|
43
|
+
# @log.debug "IterationID is #{self.iterationId};UserID is #{self.userId};This Action Cost #{rcost} seconds"
|
44
|
+
@longest = (@longest<rcost.max) ? rcost.max : @longest
|
27
45
|
@thread_pool[Thread.current][:iterationId] = iterationId
|
28
46
|
end
|
29
47
|
@counter += 1
|
30
48
|
}]={:userId=>userId}
|
31
49
|
end
|
32
|
-
|
50
|
+
# @thread_pool.keys.each{|t|t.join}
|
33
51
|
while @counter != @users do
|
34
52
|
Thread.pass
|
35
53
|
end
|
@@ -37,24 +55,52 @@ module RoadRunnerModule
|
|
37
55
|
when /process/,/p/ then
|
38
56
|
proc {
|
39
57
|
ppid=Process.pid
|
40
|
-
@log.info("Main Process pid => #{ppid}")
|
58
|
+
# @log.info("Main Process pid => #{ppid}")
|
41
59
|
|
42
60
|
pids=[]
|
43
61
|
@users.times { |userId|
|
44
62
|
pids << Process.fork {
|
63
|
+
rcost = {}
|
45
64
|
@userId=userId
|
46
65
|
@iterations.times do |iterationId|
|
47
66
|
@iterationId=iterationId
|
48
67
|
|
49
|
-
rcost = 0
|
50
68
|
@transaction_blk.each_pair{|k,v|
|
51
|
-
rcost
|
69
|
+
rcost[k]=[] unless rcost[k]
|
70
|
+
rcost[k] << self.transaction(k,&v)
|
71
|
+
# self.log.info("rcost => #{rcost.inspect}")
|
52
72
|
}
|
53
73
|
|
54
|
-
# rcost = self.transaction('Action',&@actBlk)
|
55
|
-
@longest = (@longest<rcost)?rcost:@longest
|
56
74
|
end
|
57
|
-
|
75
|
+
|
76
|
+
# >> r
|
77
|
+
# => {:y=>[2, 1, 5, 9], :x=>[1, 2, 3, 4]}
|
78
|
+
# >> r.map{|x|{x[0]=>x[1].max}}
|
79
|
+
# => [{:y=>9}, {:x=>4}]
|
80
|
+
m=0
|
81
|
+
rcost.map{|x|{x[0]=>x[1].max}}.each{|h|
|
82
|
+
if(h.values[0]>m)
|
83
|
+
@longest=h
|
84
|
+
end
|
85
|
+
}
|
86
|
+
|
87
|
+
succRates = getSuccessRate @transactions
|
88
|
+
|
89
|
+
preport=
|
90
|
+
<<-DOC
|
91
|
+
<PID:#{Process.pid}> <UserId:#{@userId}>
|
92
|
+
#{'Process Transaction Report'.center(50, '-')}
|
93
|
+
#{@transactions.inject("") { |str,k|
|
94
|
+
str += "#{k[0].to_s} : count => #{k[1].size} time(s) , cost => #{k[1].inject(0){|c,v|c+=v[:cost].to_f}.to_s[0..3]} sec(s) , success rate => #{succRates[k[0]]}#{$/}"
|
95
|
+
}.gsub(/\n$/,'')}
|
96
|
+
#{'--'*32}
|
97
|
+
DOC
|
98
|
+
self.log.info(preport)
|
99
|
+
puts(preport)
|
100
|
+
|
101
|
+
# @log.info @longest.inspect
|
102
|
+
@log.info("<PID:#{Process.pid}> going down.Longest job(#{@longest.keys[0]}) cost #{@longest.values[0]}")
|
103
|
+
p ("<PID:#{Process.pid}> going down.Longest job(#{@longest.keys[0]}) cost #{@longest.values[0]}")
|
58
104
|
|
59
105
|
Process.kill("HUP", ppid)
|
60
106
|
}
|
@@ -83,9 +129,9 @@ module RoadRunnerModule
|
|
83
129
|
@users.times do |userId|
|
84
130
|
@userId=userId
|
85
131
|
|
86
|
-
rcost =
|
132
|
+
rcost = []
|
87
133
|
@transaction_blk.each_pair{|k,v|
|
88
|
-
rcost
|
134
|
+
rcost << self.transaction(k,&v)
|
89
135
|
}
|
90
136
|
|
91
137
|
# rcost = self.transaction('Action',&@actBlk)
|
@@ -93,7 +139,7 @@ module RoadRunnerModule
|
|
93
139
|
# => the below sentence cost a lot of system resource
|
94
140
|
# => if you run for production result,keep it annotated!!!
|
95
141
|
# self.log.debug "IterationID is #{self.iterationId};UserID is #{self.userId};This Action Cost #{rcost} seconds"
|
96
|
-
@longest = (@longest<rcost)?rcost
|
142
|
+
@longest = (@longest<rcost.max) ? rcost.max : @longest
|
97
143
|
end
|
98
144
|
end
|
99
145
|
}
|
data/log/stdout.log
CHANGED
@@ -1,4 +1,151 @@
|
|
1
|
-
|
2
|
-
D, [2010-04-
|
3
|
-
I, [2010-04-
|
4
|
-
I, [2010-04-
|
1
|
+
I, [2010-04-25T15:38:35.374857 #30702] INFO -- : -------------------- /Users/Cui/NetBeansProjects/roadrunner/roadrunner/test/prime_p.rb RoadRunner log --------------------
|
2
|
+
D, [2010-04-25T15:38:35.375095 #30702] DEBUG -- : Mode => p
|
3
|
+
I, [2010-04-25T15:38:35.408220 #30702] INFO -- : Waiting Processes => [30703, 30704, 30705, 30706, 30707]
|
4
|
+
I, [2010-04-25T15:38:35.753897 #30704] INFO -- : <PID:30704> <UserId:1>
|
5
|
+
----------------Transaction Report----------------
|
6
|
+
a : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
7
|
+
actoin : count => 50 time(s) , cost => 0.35 sec(s) , success rate => 1.0
|
8
|
+
init : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
9
|
+
b : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
10
|
+
----------------------------------------------------------------
|
11
|
+
|
12
|
+
I, [2010-04-25T15:38:35.754286 #30704] INFO -- : {"actoin"=>0.0302779674530029}
|
13
|
+
I, [2010-04-25T15:38:35.754386 #30704] INFO -- : <PID:30704> going down.Longest job(actoin) cost 0.0302779674530029
|
14
|
+
I, [2010-04-25T15:38:35.771185 #30702] INFO -- : One User(Process) done.
|
15
|
+
I, [2010-04-25T15:38:35.749561 #30703] INFO -- : <PID:30703> <UserId:0>
|
16
|
+
----------------Transaction Report----------------
|
17
|
+
a : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
18
|
+
actoin : count => 50 time(s) , cost => 0.35 sec(s) , success rate => 1.0
|
19
|
+
init : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
20
|
+
b : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
21
|
+
----------------------------------------------------------------
|
22
|
+
|
23
|
+
I, [2010-04-25T15:38:35.778149 #30703] INFO -- : {"actoin"=>0.0359859466552734}
|
24
|
+
I, [2010-04-25T15:38:35.778264 #30703] INFO -- : <PID:30703> going down.Longest job(actoin) cost 0.0359859466552734
|
25
|
+
I, [2010-04-25T15:38:35.780912 #30702] INFO -- : One User(Process) done.
|
26
|
+
I, [2010-04-25T15:38:35.851359 #30706] INFO -- : <PID:30706> <UserId:3>
|
27
|
+
----------------Transaction Report----------------
|
28
|
+
a : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
29
|
+
actoin : count => 50 time(s) , cost => 0.41 sec(s) , success rate => 1.0
|
30
|
+
init : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
31
|
+
b : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
32
|
+
----------------------------------------------------------------
|
33
|
+
|
34
|
+
I, [2010-04-25T15:38:35.851809 #30706] INFO -- : {"actoin"=>0.0388009548187256}
|
35
|
+
I, [2010-04-25T15:38:35.851909 #30706] INFO -- : <PID:30706> going down.Longest job(actoin) cost 0.0388009548187256
|
36
|
+
I, [2010-04-25T15:38:35.852186 #30702] INFO -- : One User(Process) done.
|
37
|
+
I, [2010-04-25T15:38:35.861282 #30705] INFO -- : <PID:30705> <UserId:2>
|
38
|
+
----------------Transaction Report----------------
|
39
|
+
a : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
40
|
+
actoin : count => 50 time(s) , cost => 0.40 sec(s) , success rate => 1.0
|
41
|
+
init : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
42
|
+
b : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
43
|
+
----------------------------------------------------------------
|
44
|
+
|
45
|
+
I, [2010-04-25T15:38:35.861756 #30705] INFO -- : {"actoin"=>0.0417690277099609}
|
46
|
+
I, [2010-04-25T15:38:35.861864 #30705] INFO -- : <PID:30705> going down.Longest job(actoin) cost 0.0417690277099609
|
47
|
+
I, [2010-04-25T15:38:35.863333 #30702] INFO -- : One User(Process) done.
|
48
|
+
I, [2010-04-25T15:38:35.866110 #30707] INFO -- : <PID:30707> <UserId:4>
|
49
|
+
----------------Transaction Report----------------
|
50
|
+
a : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
51
|
+
actoin : count => 50 time(s) , cost => 0.42 sec(s) , success rate => 1.0
|
52
|
+
init : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
53
|
+
b : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
54
|
+
----------------------------------------------------------------
|
55
|
+
|
56
|
+
I, [2010-04-25T15:38:35.866563 #30707] INFO -- : {"actoin"=>0.0417959690093994}
|
57
|
+
I, [2010-04-25T15:38:35.866670 #30707] INFO -- : <PID:30707> going down.Longest job(actoin) cost 0.0417959690093994
|
58
|
+
I, [2010-04-25T15:38:35.867903 #30702] INFO -- : One User(Process) done.
|
59
|
+
I, [2010-04-25T15:38:40.409172 #30702] INFO -- : Processes down.
|
60
|
+
I, [2010-04-25T15:38:40.412344 #30702] INFO -- : ***************Performance Reports****************
|
61
|
+
|
62
|
+
user system total real
|
63
|
+
|
64
|
+
0.000000 0.000000 0.870000 ( 5.034264)
|
65
|
+
|
66
|
+
----------------------------------------------------------------
|
67
|
+
The Virtual User is 5.
|
68
|
+
Total Execute 250 Action(s).
|
69
|
+
Total Cost 5.034264087677 Second(s).
|
70
|
+
This Scenario's TPS : 49.6596911973602.
|
71
|
+
The longest action cost 0 seconds.
|
72
|
+
----------------Transaction Report----------------
|
73
|
+
|
74
|
+
----------------------------------------------------------------
|
75
|
+
User defined params as below:
|
76
|
+
size100
|
77
|
+
******************End of Reports******************
|
78
|
+
|
79
|
+
I, [2010-04-25T22:13:07.777877 #30988] INFO -- : -------------------- /Users/Cui/NetBeansProjects/roadrunner/roadrunner/test/prime_p.rb RoadRunner log --------------------
|
80
|
+
D, [2010-04-25T22:13:07.794956 #30988] DEBUG -- : Mode => p
|
81
|
+
I, [2010-04-25T22:13:07.842745 #30988] INFO -- : Waiting Processes => [30989, 30990, 30991, 30992, 30993]
|
82
|
+
I, [2010-04-25T22:13:08.224372 #30990] INFO -- : <PID:30990> <UserId:1>
|
83
|
+
----------------Transaction Report----------------
|
84
|
+
a : count => 50 time(s) , cost => 0.01 sec(s) , success rate => 1.0
|
85
|
+
actoin : count => 50 time(s) , cost => 0.40 sec(s) , success rate => 1.0
|
86
|
+
init : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
87
|
+
b : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
88
|
+
----------------------------------------------------------------
|
89
|
+
|
90
|
+
I, [2010-04-25T22:13:08.225105 #30990] INFO -- : <PID:30990> going down.Longest job(b) cost 0.000171899795532227
|
91
|
+
I, [2010-04-25T22:13:08.228904 #30988] INFO -- : One User(Process) done.
|
92
|
+
I, [2010-04-25T22:13:08.236709 #30991] INFO -- : <PID:30991> <UserId:2>
|
93
|
+
----------------Transaction Report----------------
|
94
|
+
a : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
95
|
+
actoin : count => 50 time(s) , cost => 0.39 sec(s) , success rate => 1.0
|
96
|
+
init : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
97
|
+
b : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
98
|
+
----------------------------------------------------------------
|
99
|
+
|
100
|
+
I, [2010-04-25T22:13:08.237150 #30991] INFO -- : <PID:30991> going down.Longest job(b) cost 0.000528097152709961
|
101
|
+
I, [2010-04-25T22:13:08.237970 #30988] INFO -- : One User(Process) done.
|
102
|
+
I, [2010-04-25T22:13:08.255347 #30989] INFO -- : <PID:30989> <UserId:0>
|
103
|
+
----------------Transaction Report----------------
|
104
|
+
a : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
105
|
+
actoin : count => 50 time(s) , cost => 0.40 sec(s) , success rate => 1.0
|
106
|
+
init : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
107
|
+
b : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
108
|
+
----------------------------------------------------------------
|
109
|
+
|
110
|
+
I, [2010-04-25T22:13:08.256252 #30989] INFO -- : <PID:30989> going down.Longest job(b) cost 3.19480895996094e-05
|
111
|
+
I, [2010-04-25T22:13:08.256544 #30988] INFO -- : One User(Process) done.
|
112
|
+
I, [2010-04-25T22:13:08.288183 #30993] INFO -- : <PID:30993> <UserId:4>
|
113
|
+
----------------Transaction Report----------------
|
114
|
+
a : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
115
|
+
actoin : count => 50 time(s) , cost => 0.42 sec(s) , success rate => 1.0
|
116
|
+
init : count => 50 time(s) , cost => 0.01 sec(s) , success rate => 1.0
|
117
|
+
b : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
118
|
+
----------------------------------------------------------------
|
119
|
+
|
120
|
+
I, [2010-04-25T22:13:08.288617 #30993] INFO -- : <PID:30993> going down.Longest job(b) cost 2.88486480712891e-05
|
121
|
+
I, [2010-04-25T22:13:08.289573 #30988] INFO -- : One User(Process) done.
|
122
|
+
I, [2010-04-25T22:13:08.323381 #30992] INFO -- : <PID:30992> <UserId:3>
|
123
|
+
----------------Transaction Report----------------
|
124
|
+
a : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
125
|
+
actoin : count => 50 time(s) , cost => 0.46 sec(s) , success rate => 1.0
|
126
|
+
init : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
127
|
+
b : count => 50 time(s) , cost => 0.00 sec(s) , success rate => 1.0
|
128
|
+
----------------------------------------------------------------
|
129
|
+
|
130
|
+
I, [2010-04-25T22:13:08.323846 #30992] INFO -- : <PID:30992> going down.Longest job(b) cost 0.000580072402954102
|
131
|
+
I, [2010-04-25T22:13:08.324217 #30988] INFO -- : One User(Process) done.
|
132
|
+
I, [2010-04-25T22:13:12.844448 #30988] INFO -- : Processes down.
|
133
|
+
I, [2010-04-25T22:13:12.848688 #30988] INFO -- : ***************Performance Reports****************
|
134
|
+
|
135
|
+
user system total real
|
136
|
+
|
137
|
+
0.000000 0.000000 0.860000 ( 5.050142)
|
138
|
+
|
139
|
+
----------------------------------------------------------------
|
140
|
+
The Virtual User is 5.
|
141
|
+
Total Execute 250 Action(s).
|
142
|
+
Total Cost 5.05014204978943 Second(s).
|
143
|
+
This Scenario's TPS : 49.5035580257439.
|
144
|
+
The longest action cost 0 seconds.
|
145
|
+
----------------Transaction Report----------------
|
146
|
+
|
147
|
+
----------------------------------------------------------------
|
148
|
+
User defined params as below:
|
149
|
+
size100
|
150
|
+
******************End of Reports******************
|
151
|
+
|
@@ -0,0 +1,4 @@
|
|
1
|
+
# Logfile created on Thu Apr 22 17:32:25 +0800 2010 by logger.rb/22285
|
2
|
+
D, [2010-04-22T17:32:25.408228 #25471] DEBUG -- : Mode => p
|
3
|
+
I, [2010-04-22T17:32:25.426651 #25471] INFO -- : Main Process pid => 25471
|
4
|
+
I, [2010-04-22T17:32:25.570585 #25471] INFO -- : Waiting Processes => [25472, 25473, 25474, 25475, 25476, 25477, 25478, 25479, 25480, 25481]
|
data/test/pi.rb
CHANGED
@@ -26,6 +26,8 @@ rrpi.action do
|
|
26
26
|
1.upto(rrpi.global[:deep]){|x|rrpi.global[:pi]+=((-1)**(x+1)*1.0/(x*2-1))}
|
27
27
|
end
|
28
28
|
|
29
|
+
rrpi.else{(1..rand(10000)).max}
|
30
|
+
|
29
31
|
rrpi.ended do
|
30
32
|
rrpi.global[:pi]*=4
|
31
33
|
#rrpi.global={}
|
@@ -35,3 +37,35 @@ rrpi.run
|
|
35
37
|
rrpi.report
|
36
38
|
|
37
39
|
p "Tps could get : RoadRunner::tps => #{rrpi.tps}"
|
40
|
+
|
41
|
+
__END__
|
42
|
+
|
43
|
+
" ********************RoadRunner********************"
|
44
|
+
" * ---Run , on your way.*"
|
45
|
+
" **************************************************"
|
46
|
+
" Running......"
|
47
|
+
" Ending......"
|
48
|
+
" Wait for moment,the report is collecting......"
|
49
|
+
***************Performance Reports****************
|
50
|
+
|
51
|
+
user system total real
|
52
|
+
|
53
|
+
31.640000 17.210000 48.850000 ( 49.354817)
|
54
|
+
|
55
|
+
----------------------------------------------------------------
|
56
|
+
The Virtual User is 10.
|
57
|
+
Total Execute 10000 Action(s).
|
58
|
+
Total Cost 49.3548169136047 Second(s).
|
59
|
+
This Scenario's TPS : 202.614468563523.
|
60
|
+
The longest action cost 0.0503699779510498 seconds.
|
61
|
+
----------------Transaction Report----------------
|
62
|
+
else : count => 10000 time(s) , cost => 43.1 sec(s) , success rate => 1.0
|
63
|
+
end : count => 10000 time(s) , cost => 0.03 sec(s) , success rate => 1.0
|
64
|
+
actoin : count => 10000 time(s) , cost => 5.12 sec(s) , success rate => 1.0
|
65
|
+
init : count => 10000 time(s) , cost => 0.07 sec(s) , success rate => 1.0
|
66
|
+
|
67
|
+
----------------------------------------------------------------
|
68
|
+
User defined params as below:
|
69
|
+
pi0deep100
|
70
|
+
******************End of Reports******************
|
71
|
+
"Tps could get : RoadRunner::tps => 202.614468563523"
|
data/test/prime_p.rb
CHANGED
@@ -14,23 +14,22 @@ rrprime.init do
|
|
14
14
|
# rrprime.global是一个存储全局变量的方法
|
15
15
|
# 任何数据类型都可以丢进去
|
16
16
|
# 在执行report方法时,rrprime.global中的数据会被打印到报告中
|
17
|
-
rrprime.global[:size]=
|
17
|
+
rrprime.global[:size]=100
|
18
18
|
|
19
19
|
# users决定同时有多少并发用户一起执行action
|
20
20
|
# iterations决定每个用户执行多少次
|
21
|
-
rrprime.users,rrprime.iterations=
|
21
|
+
rrprime.users,rrprime.iterations=5,50
|
22
22
|
end
|
23
23
|
|
24
24
|
rrprime.action do
|
25
|
-
|
25
|
+
# print "Action "+rrprime.userId.to_s+" "+Time.now.to_s+$/
|
26
26
|
# 得到素数数组
|
27
27
|
rrprime.global[:result]=(2..rrprime.global[:size]).inject([]) { |s, e| (s.map { |x| e % x }).include?(0) ? s : s << e }
|
28
28
|
end
|
29
29
|
|
30
|
-
rrprime.
|
31
|
-
rrprime.
|
32
|
-
|
33
|
-
|
30
|
+
# rrprime.log.info
|
31
|
+
rrprime.a{"A-Tranction "+rrprime.userId.to_s+" "+Time.now.to_s+$/}
|
32
|
+
rrprime.b{"B-Tranction "+rrprime.userId.to_s+" "+Time.now.to_s+$/}
|
34
33
|
|
35
34
|
rrprime.run
|
36
35
|
rrprime.report
|
data/test/vbd_kv.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require File.join(File.dirname(__FILE__),'..','lib','roadrunner')
|
3
|
+
# require "roadrunner"
|
3
4
|
|
4
5
|
#-----------------------------Argv prepare.--------------------------------#
|
5
6
|
|
@@ -10,8 +11,8 @@ def args(key)
|
|
10
11
|
nil
|
11
12
|
end
|
12
13
|
|
13
|
-
unless args('nbd')
|
14
|
-
p "[ruby ]#{$0} -nbd /dev/nbd[0-x][,/dev/nbd[0-x],/dev/nbd[0-x]]"
|
14
|
+
unless args('nbd') && args('size')
|
15
|
+
p "[ruby ]#{$0} -nbd /dev/nbd[0-x][,/dev/nbd[0-x],/dev/nbd[0-x]] -size 10240000"
|
15
16
|
exit 1
|
16
17
|
end
|
17
18
|
|
@@ -33,20 +34,23 @@ args('nbd').split(',').each do |n|
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
37
|
+
`echo '' > /root/nbd/sanbo/1.log`
|
38
|
+
|
36
39
|
#--------------------------------VBD KV integration test---------------------------------#
|
37
40
|
|
38
41
|
class ValidateError < Exception;end
|
39
|
-
|
42
|
+
|
40
43
|
class Kv_vbd
|
41
44
|
class << self
|
42
45
|
def seq_read(nbd,fs)
|
46
|
+
$log.debug("Entry seq_read, ARGV => #{ARGV.inspect}")
|
43
47
|
begin
|
44
48
|
nbd.rewind# if nbd.eof?
|
45
49
|
|
46
50
|
loop {
|
47
51
|
tmp=rand(fs/10000)
|
48
52
|
# $log.debug("seq_read:reading #{tmp} bytes from #{nbd}")
|
49
|
-
tmp=nbd.
|
53
|
+
tmp=nbd.readpartial(tmp)
|
50
54
|
break if nbd.eof?
|
51
55
|
}
|
52
56
|
|
@@ -54,70 +58,138 @@ class Kv_vbd
|
|
54
58
|
rescue Exception => e
|
55
59
|
$log.error("#{nbd} read error!")
|
56
60
|
end
|
57
|
-
validate(nbd,fs)
|
61
|
+
# validate(nbd,fs)
|
58
62
|
end
|
59
63
|
|
60
64
|
def seq_write(nbd,fs)
|
65
|
+
$log.debug("Entry seq_write, ARGV => #{ARGV.inspect}")
|
61
66
|
begin
|
62
67
|
nbd.rewind# if nbd.eof?
|
63
68
|
|
64
|
-
bs=
|
69
|
+
# bs=1024*1024
|
70
|
+
bs=1024
|
71
|
+
data='x'*bs
|
65
72
|
|
66
|
-
$log.debug("
|
73
|
+
$log.debug("seq_write:writing #{bs} bytes into #{nbd} everytime.")
|
67
74
|
|
68
|
-
fs/bs.times {
|
69
|
-
nbd.syswrite(
|
75
|
+
(fs/bs).times {|t|
|
76
|
+
nbd.syswrite(data)
|
77
|
+
nbd.flush
|
78
|
+
# `sync` if t%10240 == 0
|
70
79
|
}
|
80
|
+
(nbd.syswrite('x'*(fs%bs));nbd.flush) unless fs%bs == 0
|
71
81
|
|
72
|
-
|
82
|
+
$log.info("ruby io done.sync will exec.")
|
83
|
+
`sync`
|
84
|
+
# signature(nbd,fs)
|
73
85
|
|
74
86
|
$log.info("seq_write done.#{fs} bytes write into #{nbd}.")
|
75
87
|
rescue Exception => e
|
76
88
|
$log.error("#{nbd} write error!")
|
77
89
|
end
|
78
|
-
|
90
|
+
dirty_watcher(nbd,fs)
|
79
91
|
end
|
80
92
|
|
81
93
|
def signature(nbd,fs)
|
82
|
-
|
94
|
+
$log.debug("Entry signature, ARGV => #{ARGV.inspect}")
|
95
|
+
|
96
|
+
nbd.rewind
|
97
|
+
nbd.seek(10)
|
83
98
|
nbd.syswrite('c')
|
84
99
|
|
85
100
|
nbd.seek(-10, IO::SEEK_END)
|
86
101
|
nbd.syswrite('c')
|
102
|
+
|
103
|
+
begin
|
104
|
+
@MD5=`md5sum #{nbd.path}`.match(/(^[a-z0-9A-Z]*)[\s|\t].*$/)[1]
|
105
|
+
$log.info("#{nbd.path} md5sum => #{@MD5}")
|
106
|
+
rescue Exception => e
|
107
|
+
$log.error("md5sum exec error! "+e.to_s)
|
108
|
+
end
|
109
|
+
|
87
110
|
end
|
88
111
|
|
89
112
|
def validate(nbd,fs)
|
90
|
-
|
91
|
-
unless nbd.sysread(1) == 'c'
|
92
|
-
raise ValidateError,"expect File.seek(10, IO::SEEK_END) => 'c',actually get #{tmp}."
|
93
|
-
end
|
113
|
+
$log.debug("Entry validate, ARGV => #{ARGV.inspect}")
|
94
114
|
|
95
|
-
nbd.
|
96
|
-
|
97
|
-
|
115
|
+
nbd.rewind
|
116
|
+
nbd.seek(10)
|
117
|
+
unless (tmp=nbd.sysread(1)) == 'c'
|
118
|
+
raise ValidateError,"expect File.seek(10, IO::SEEK_END) => 'c',actually get #{tmp}."
|
98
119
|
end
|
99
120
|
|
100
121
|
nbd.seek(-10, IO::SEEK_END)
|
101
|
-
unless nbd.sysread(1) == 'c'
|
122
|
+
unless (tmp=nbd.sysread(1)) == 'c'
|
102
123
|
raise ValidateError,"expect File.seek(-10, IO::SEEK_END) => 'c',actually get #{tmp}."
|
103
124
|
end
|
125
|
+
|
126
|
+
|
127
|
+
raise ArgumentError,"No md5sum checked! @MD5 => #{@MD5}" unless @MD5
|
128
|
+
_m=`md5sum #{nbd.path}`.match(/(^[a-z0-9A-Z]*)[\s|\t].*$/)[1]
|
129
|
+
$log.info("Expect md5sum is #{@MD5}.")
|
130
|
+
$log.info("Actually md5sum is #{_m}")
|
131
|
+
unless @MD5 == _m
|
132
|
+
raise Exception,"md5sum check failed!"
|
133
|
+
end
|
134
|
+
|
135
|
+
$log.info("Validate Success...")
|
136
|
+
end
|
137
|
+
|
138
|
+
# size => get nbd device size used at Linux system
|
139
|
+
# return nbd size(Byte)
|
140
|
+
# nbd => "/dev/nbd9"
|
141
|
+
def size(nbd)
|
142
|
+
_s=`ps axf|grep #{nbd}|tail -n1|awk '{print $8}'`.to_i*1024**3
|
143
|
+
$log.info("Disk size => #{_s}")
|
144
|
+
end
|
145
|
+
|
146
|
+
def dirty_watcher(nbd,fs)
|
147
|
+
$log.debug("Entry dirty_watcher, ARGV => #{ARGV.inspect}")
|
148
|
+
|
149
|
+
dirty=''
|
150
|
+
# watch dirty file 10 times,ensure the queue is empty.
|
151
|
+
count=10
|
152
|
+
begin
|
153
|
+
dirty="/tmp/#{`ps axf|grep 'nbd-client .* #{nbd.path}'|tail -n1|awk '{print $8}'`.gsub($/,'')}.dirty"
|
154
|
+
loop {
|
155
|
+
if IO::read(dirty) == '0'*8
|
156
|
+
count-=1
|
157
|
+
|
158
|
+
if count == 0
|
159
|
+
$log.info("dirty file <#{dirty}> == #{IO::read(dirty)}.Watch over.")
|
160
|
+
break
|
161
|
+
end
|
162
|
+
else
|
163
|
+
count=10
|
164
|
+
end
|
165
|
+
sleep 3
|
166
|
+
}
|
167
|
+
rescue Exception => e
|
168
|
+
$log.error "can't find dirty file => #{dirty}"
|
169
|
+
$log.error "ps axf|grep 'nbd-client .* #{nbd.path}' => #{`ps axf|grep 'nbd-client .* #{nbd.path}'`}"
|
170
|
+
end
|
104
171
|
end
|
105
172
|
|
106
173
|
end
|
107
174
|
end
|
108
175
|
|
109
176
|
|
177
|
+
#--------------------------------RoadRunner---------------------------------#
|
178
|
+
|
110
179
|
rr=RoadRunner.new
|
111
180
|
rr.mode,rr.users,rr.iterations='p',NBD.size,1
|
112
181
|
|
113
|
-
|
182
|
+
rr.log=$log
|
183
|
+
|
184
|
+
['seq_write','signature','seq_read','validate'].each_with_index{|s,i|
|
114
185
|
ts_proc=proc{
|
115
|
-
Kv_vbd.send(s,NBD[rr.userId],
|
186
|
+
# Kv_vbd.send(s,NBD[rr.userId],Kv_vbd.size(NBD[rr.userId].path))
|
187
|
+
Kv_vbd.send(s,NBD[rr.userId],args('size').to_i)
|
116
188
|
}
|
117
189
|
rr.send(s,&ts_proc)
|
118
190
|
}
|
119
191
|
|
120
|
-
NBD.close
|
121
|
-
|
122
192
|
rr.run
|
123
|
-
rr.report
|
193
|
+
rr.report
|
194
|
+
|
195
|
+
NBD.each{|x|x.close}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roadrunner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Cui
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-04-
|
12
|
+
date: 2010-04-26 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- log/log.rb
|
51
51
|
- log/stdout.log
|
52
52
|
- log/stdout.log.20100421
|
53
|
+
- log/stdout.log.20100422
|
53
54
|
- log/svn.log
|
54
55
|
- test/baidu.rb
|
55
56
|
- test/blog.rb
|