performance_tester 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/performance_tester.rb +12 -0
- data/lib/performance_tester/csv_logger.rb +1 -0
- data/lib/performance_tester/logger.rb +1 -0
- data/lib/performance_tester/outcome.rb +2 -0
- data/lib/performance_tester/puts_aggregate_logger.rb +7 -2
- data/lib/performance_tester/runner.rb +1 -0
- data/lib/performance_tester/version.rb +1 -1
- metadata +1 -1
data/lib/performance_tester.rb
CHANGED
@@ -3,3 +3,15 @@ require 'performance_tester/runner'
|
|
3
3
|
require 'performance_tester/scenario'
|
4
4
|
require 'performance_tester/version'
|
5
5
|
require 'performance_tester/logger'
|
6
|
+
|
7
|
+
module PerformanceTester
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def build_scenario(&block)
|
11
|
+
Scenario.new(&block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def run_scenario(scenario, options = {})
|
15
|
+
Runner.new(options).run(scenario)
|
16
|
+
end
|
17
|
+
end
|
@@ -32,6 +32,7 @@ module PerformanceTester
|
|
32
32
|
error ? error.to_s : requests.map(&:to_s).inspect
|
33
33
|
end
|
34
34
|
|
35
|
+
# Models an executed http request
|
35
36
|
class Request
|
36
37
|
attr_reader :url, :request_time, :response, :host_aliases
|
37
38
|
|
@@ -86,6 +87,7 @@ module PerformanceTester
|
|
86
87
|
NullResponse.new(request_time, 0, '')
|
87
88
|
end
|
88
89
|
|
90
|
+
# Models the odd case where a request has no response parts
|
89
91
|
class NullResponse < Struct.new(:time, :status, :content_type); end
|
90
92
|
end
|
91
93
|
end
|
@@ -1,13 +1,18 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module PerformanceTester
|
4
|
+
# Prints summary data to stdout
|
4
5
|
class PutsAggregateLogger < Logger
|
5
6
|
def log
|
6
7
|
puts "Test run: #{run_name}"
|
7
8
|
puts "Success: #{outcome.success?}"
|
8
9
|
puts "Number of requests: #{number_of_requests}"
|
9
|
-
puts "Sum of request times: #{
|
10
|
-
puts "Total time elapsed: #{
|
10
|
+
puts "Sum of request times: #{d(sum_of_times_of_all_requests)}"
|
11
|
+
puts "Total time elapsed: #{d(total_time_elapsed)}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def d(value)
|
15
|
+
sprintf("%.02f", value)
|
11
16
|
end
|
12
17
|
|
13
18
|
def total_time_elapsed
|