Class: Jtl
- Inherits:
-
Object
show all
- Defined in:
- lib/jtl/jtl.rb,
lib/jtl/version.rb
Defined Under Namespace
Classes: DataSet, LabeledValue
Constant Summary
collapse
- COLUMNS =
[
:time_stamp,
:elapsed,
:label,
:response_code,
:response_message,
:thread_name,
:data_type,
:success,
:bytes,
:latency,
]
- VERSION =
'0.1.5'
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path_or_file_or_ary, options = {}) ⇒ Jtl
Returns a new instance of Jtl.
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/jtl/jtl.rb', line 22
def initialize(path_or_file_or_ary, options = {})
@options = {:interval => 1000}.merge(options)
if path_or_file_or_ary.kind_of?(Array)
@jtl = path_or_file_or_ary
else
path_or_file_or_ary = path_or_file_or_ary.path if path_or_file_or_ary.kind_of?(File)
@jtl = CSV.read(path_or_file_or_ary)
end
end
|
Class Method Details
.parse_time_stamp(ts) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/jtl/jtl.rb', line 15
def self.parse_time_stamp(ts)
ts = ts.to_i
msec = (ts % 1000)
ts = ((ts - msec) / 1000).to_i
Time.at(ts, msec * 1000)
end
|
Instance Method Details
#bytes(&block) ⇒ Object
97
98
99
100
|
# File 'lib/jtl/jtl.rb', line 97
def bytes(&block)
data_set = aggregate_by(:bytes) {|v| v.to_i }
DataSet.create(data_set, self, &block)
end
|
#data_types(&block) ⇒ Object
87
88
89
90
|
# File 'lib/jtl/jtl.rb', line 87
def data_types(&block)
data_set = aggregate_by(:data_type)
DataSet.create(data_set, self, &block)
end
|
#elapseds(&block) ⇒ Object
67
68
69
70
|
# File 'lib/jtl/jtl.rb', line 67
def elapseds(&block)
data_set = aggregate_by(:elapsed) {|v| v.to_i }
DataSet.create(data_set, self, &block)
end
|
#flatten ⇒ Object
50
51
52
|
# File 'lib/jtl/jtl.rb', line 50
def flatten
self.class.new(@jtl, @options.merge(:interval => nil))
end
|
#interval ⇒ Object
41
42
43
|
# File 'lib/jtl/jtl.rb', line 41
def interval
@options[:interval]
end
|
#interval=(v) ⇒ Object
45
46
47
48
|
# File 'lib/jtl/jtl.rb', line 45
def interval=(v)
@options[:interval] = v
@aggregated_rows = nil
end
|
#labels ⇒ Object
54
55
56
|
# File 'lib/jtl/jtl.rb', line 54
def labels
@jtl.inject({}) {|r, i| r[label(i)] = true; r }.keys
end
|
#latencies(&block) ⇒ Object
102
103
104
105
|
# File 'lib/jtl/jtl.rb', line 102
def latencies(&block)
data_set = aggregate_by(:latency) {|v| v.to_i }
DataSet.create(data_set, self, &block)
end
|
#response_codes(&block) ⇒ Object
72
73
74
75
|
# File 'lib/jtl/jtl.rb', line 72
def response_codes(&block)
data_set = aggregate_by(:response_code) {|v| v.to_i }
DataSet.create(data_set, self, &block)
end
|
#response_messages(&block) ⇒ Object
82
83
84
85
|
# File 'lib/jtl/jtl.rb', line 82
def response_messages(&block)
data_set = aggregate_by(:response_message)
DataSet.create(data_set, self, &block)
end
|
#scale_marks ⇒ Object
58
59
60
|
# File 'lib/jtl/jtl.rb', line 58
def scale_marks
aggregate_rows.map {|k, v| k }
end
|
#successes(&block) ⇒ Object
92
93
94
95
|
# File 'lib/jtl/jtl.rb', line 92
def successes(&block)
data_set = aggregate_by(:success) {|v| v == 'true' }
DataSet.create(data_set, self, &block)
end
|
#thread_names(&block) ⇒ Object
77
78
79
80
|
# File 'lib/jtl/jtl.rb', line 77
def thread_names(&block)
data_set = aggregate_by(:thread_name)
DataSet.create(data_set, self, &block)
end
|
#time_stamps(&block) ⇒ Object
62
63
64
65
|
# File 'lib/jtl/jtl.rb', line 62
def time_stamps(&block)
data_set = aggregate_by(:time_stamp) {|v| v.to_i }
DataSet.create(data_set, self, &block)
end
|
#write(output_path) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/jtl/jtl.rb', line 33
def write(output_path)
CSV.open(output_path, 'wb') do |csv|
@jtl.each do |row|
csv << row
end
end
end
|