Module: Card::Set::Self::PerformanceLog
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod007-05_standard/self/performance_log.rb
Instance Method Summary
collapse
Methods included from Card::Set
abstract_set?, all_set?, clean_empty_module_from_hash, clean_empty_modules, define_on_format, each_format, ensure_set, extended, format, include_set, include_set_formats, process_base_module_list, process_base_modules, register_set, register_set_format, shortname, stage_method, view, write_tmp_file
Methods included from Trait
#card_accessor, #card_reader, #card_writer
Methods included from Event
#define_event, #event
Instance Method Details
#add_csv_entry(page, wbench_data, runs) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'tmpsets/set/mod007-05_standard/self/performance_log.rb', line 33
def add_csv_entry page, wbench_data, runs
if !File.exists? csv_path
File.open(csv_path, 'w') { |f| f.puts "page,render time, dom loading time, connection time"}
end
browser = wbench_data.browser
runs.times do |i|
csv_data = [
page,
browser['responseEnd'][i] - browser['requestStart'][i],
browser['domComplete'][i] - browser['domLoading'][i], browser['requestStart'][i], ]
csv_line = CSV.generate_line(csv_data)
File.open(csv_path, 'a') { |f| f.puts csv_line }
end
end
|
#add_log_entry(request, html_log) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'tmpsets/set/mod007-05_standard/self/performance_log.rb', line 17
def add_log_entry request, html_log
time = DateTime.now.utc.strftime "%Y%m%d%H%M%S"
name = "%s+%s %s" % [Card[:performance_log].name, time, request.gsub('/','/') ]
if Card.fetch name
name += 'a'
while Card.fetch name
name.next!
end
end
Card::Auth.as_bot do
File.open(Card[:performance_log].log_path(name), 'w') {|f| f.puts html_log}
Card[:performance_log].add_item! name
end
end
|
13
14
15
|
# File 'tmpsets/set/mod007-05_standard/self/performance_log.rb', line 13
def csv_path
File.join log_dir, "#{Card[:performance_log].codename}.csv"
end
|
3
4
5
6
7
|
# File 'tmpsets/set/mod007-05_standard/self/performance_log.rb', line 3
def log_dir
dir = File.join File.dirname(Wagn.paths['log'].existent.first), 'performance'
Dir.mkdir dir unless Dir.exists? dir
dir
end
|
#log_path(item) ⇒ Object
9
10
11
|
# File 'tmpsets/set/mod007-05_standard/self/performance_log.rb', line 9
def log_path item
File.join log_dir, "#{item.gsub('/','_').gsub(/[^0-9A-Za-z.\-]/, '_')}.log"
end
|