Class: InternetHakai::TimeRegister
Overview
Constant Summary
collapse
- UNIQUE_BY_THREAD =
false
Instance Method Summary
collapse
Methods inherited from BaseHandler
clear, clearall, get_class, get_config, get_handler, get_instance, get_instance_thread, get_thread_id, #initialize, set_config, set_thread_id, unique_by_thread?
Instance Method Details
#do_regist(name, time, response, error) ⇒ Object
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
|
# File 'lib/internethakai/time_register.rb', line 22
def do_regist name, time, response, error
time = time.to_f
v = @report[name]
if response.nil?
status = 0
else
status = response.status
v[:size] += response.body.size
end
if v[:min].nil? and time != 0
v[:min] = time
v[:max] = time
elsif time != 0
v[:min] = v[:min] < time ? v[:min] : time
end
if time != 0
v[:max] = v[:max] > time ? v[:max] : time
end
v[:totaltime] += time v[:accesscount] += 1 if time > 0
v[:errorcount] += error
v["status:#{status}"] = v["status:#{status}"].to_i + 1 unless response.nil?
v["time:#{((time*1000).to_i/100)*100}"] = v["time:#{((time*1000).to_i/100)*100}"].to_i + 1
end
|
#exec ⇒ Object
13
14
15
16
17
18
|
# File 'lib/internethakai/time_register.rb', line 13
def exec
for arg in @stack
do_regist(*arg)
end
@stack = []
end
|
#get_record ⇒ Object
9
10
11
12
|
# File 'lib/internethakai/time_register.rb', line 9
def get_record
exec unless @stack.empty?
@report
end
|
#on_create ⇒ Object
5
6
7
8
|
# File 'lib/internethakai/time_register.rb', line 5
def on_create
@report = ResponseRecord::new
@stack = []
end
|
#regist(name, time, response, error) ⇒ Object
19
20
21
|
# File 'lib/internethakai/time_register.rb', line 19
def regist name, time, response, error
@stack << [name, time, response, error]
end
|