Class: InternetHakai::TimeRegister

Inherits:
BaseHandler show all
Defined in:
lib/internethakai/time_register.rb

Overview

時間記録

Direct Known Subclasses

PipeTimeRegister, RevTimeRegister

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?

Constructor Details

This class inherits a constructor from InternetHakai::BaseHandler

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 (response.nil? || (status != 200 && (status / 100 != 3)))
    #    v[:errorcount] += 1 ## エラーカウント
    #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
    #detail は 一度だけ上書き
    #v[:detail] += detail if(detail != "" && v[:detail]=="")
end

#execObject



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_recordObject



9
10
11
12
# File 'lib/internethakai/time_register.rb', line 9

def get_record
    exec unless @stack.empty?
    @report
end

#on_createObject



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