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.
@@ -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
@@ -2,6 +2,7 @@
2
2
  require 'csv'
3
3
 
4
4
  module PerformanceTester
5
+ # Writes or appends csv data to the filesystem
5
6
  class CsvLogger < Logger
6
7
  def path
7
8
  options.fetch(:path) { 'performance_test.csv' }
@@ -17,6 +17,7 @@ module PerformanceTester
17
17
  raise ArgumentError, "Unregistered logger: #{name}"
18
18
  end
19
19
 
20
+ # Base logger with a stub log method
20
21
  class Logger
21
22
  attr_reader :run_name, :outcome, :options
22
23
 
@@ -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: #{sprintf("%.02f", sum_of_times_of_all_requests)}"
10
- puts "Total time elapsed: #{sprintf("%.02f", 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
@@ -84,6 +84,7 @@ module PerformanceTester
84
84
  options.fetch(:driver) { Capybara::Poltergeist::Driver }
85
85
  end
86
86
 
87
+ # Provides an execution context for scenarios
87
88
  class Context
88
89
  include Capybara::DSL
89
90
 
@@ -1,3 +1,3 @@
1
1
  module PerformanceTester
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: performance_tester
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: