celluloid-benchmark 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d6ca6a307e6c743b6024e66193242e30daebf58
4
- data.tar.gz: 13a15f647b8b7fb852f92930e6f16ed3d23019fb
3
+ metadata.gz: b1bcbca7e7bf8b09222882ba6621285dd3911c71
4
+ data.tar.gz: 8fcfae1dd2a0df63f90b3fe084996f6389b9cda9
5
5
  SHA512:
6
- metadata.gz: fafc822aa34fbde4808ec16a08d3752621bdb5d8c10eb2333c78e2414a00b04a303a3981c14c129ce956f3e4cd12950f114fc0cba90d01792aa3f462536a5cf1
7
- data.tar.gz: 03fd8a7cc021d5a1ef7f77c9abd647b752b762a5a7c8c98b6b1e3ac47e250263e71615e7c1c28e0dddd2d4a5f819d7b97c0597d400fc1c110d6fad0d2c2133e2
6
+ metadata.gz: dc3e53e6134b1f12a360eb617252042e421ca94e30e89633db3396602f5f79bc1d1bc1813f74318f765d861166d2a7bd7de170596a4f0cb7d64be0fa0d340d4b
7
+ data.tar.gz: f2ddb5969d564c83a20a793387fe8917dd3ddf91f02f9da3728a086fec5dfd7606fcf67de8fbf761b60803bad6b16106484eab58384990404b409d929df0910b
data/README.md CHANGED
@@ -133,3 +133,8 @@ Develop
133
133
  rvm gemset use celluloid-benchmark --create
134
134
  bundle
135
135
  rake
136
+
137
+ CI
138
+ ==
139
+ https://travis-ci.org/scottwillson/celluloid-benchmark
140
+
@@ -44,9 +44,9 @@ module CelluloidBenchmark
44
44
  end
45
45
 
46
46
  def requests
47
- response_times.values.compact.map(&:size).reduce(&:+) || 0
47
+ response_times.values.compact.map(&:size).reduce(0, &:+)
48
48
  end
49
-
49
+
50
50
  def benchmarks
51
51
  response_times.map do |label, response_times|
52
52
  CelluloidBenchmark::Benchmark.new label, thresholds[label], response_times, response_codes[label]
@@ -0,0 +1,22 @@
1
+ module CelluloidBenchmark
2
+ module DataSources
3
+ def random_data(key)
4
+ data_source(key).sample
5
+ end
6
+
7
+ def data_sources
8
+ @data_sources ||= Hash.new do |hash, key|
9
+ hash[key] = File.readlines("tmp/data/#{key}s.csv")
10
+ end
11
+ end
12
+
13
+ def data_sources=(hash)
14
+ @data_sources = hash
15
+ end
16
+
17
+ def data_source(key)
18
+ data_sources[key]
19
+ end
20
+ end
21
+ end
22
+
@@ -1,3 +1,3 @@
1
1
  module CelluloidBenchmark
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,10 +1,13 @@
1
1
  require "mechanize"
2
+ require_relative "data_sources"
2
3
 
3
4
  module CelluloidBenchmark
4
5
  # Actor that models a person using a web browser. Runs a test scenario. Delegates web browsing to
5
6
  # instance of a Mechanize Agent.
6
7
  class Visitor
7
8
  include Celluloid
9
+ include CelluloidBenchmark::DataSources
10
+
8
11
  extend Forwardable
9
12
 
10
13
  def_delegators :@browser, :add_auth, :get, :submit, :transact
@@ -18,15 +21,7 @@ module CelluloidBenchmark
18
21
 
19
22
  def initialize(browser = Mechanize.new)
20
23
  @browser = browser
21
-
22
- browser.pre_connect_hooks << proc do |agent, request|
23
- self.request_start_time = Time.now
24
- end
25
-
26
- browser.post_connect_hooks << proc do |agent, uri, response, body|
27
- self.request_end_time = Time.now
28
- benchmark_run.async.log response.code, request_start_time, request_end_time, current_request_label, current_request_threshold
29
- end
24
+ add_browser_timing_hooks
30
25
  end
31
26
 
32
27
  def run_session(session, benchmark_run, duration)
@@ -38,14 +33,7 @@ module CelluloidBenchmark
38
33
  begin
39
34
  instance_eval session
40
35
  rescue Mechanize::ResponseCodeError => e
41
- self.request_end_time = Time.now
42
- benchmark_run.async.log(
43
- e.response_code,
44
- request_start_time,
45
- request_end_time,
46
- current_request_label,
47
- current_request_threshold
48
- )
36
+ log_response_code_error e
49
37
  end
50
38
 
51
39
  elapsed_time = Time.now - started_at
@@ -57,23 +45,30 @@ module CelluloidBenchmark
57
45
  self.current_request_label = label
58
46
  self.current_request_threshold = threshold
59
47
  end
60
-
61
- def random_data(key)
62
- data_source(key).sample
63
- end
64
48
 
65
- def data_sources
66
- @data_sources ||= Hash.new do |hash, key|
67
- hash[key] = File.readlines("tmp/data/#{key}s.csv")
49
+
50
+ private
51
+
52
+ def add_browser_timing_hooks
53
+ browser.pre_connect_hooks << proc do |agent, request|
54
+ self.request_start_time = Time.now
55
+ end
56
+
57
+ browser.post_connect_hooks << proc do |agent, uri, response, body|
58
+ self.request_end_time = Time.now
59
+ benchmark_run.async.log response.code, request_start_time, request_end_time, current_request_label, current_request_threshold
68
60
  end
69
61
  end
70
62
 
71
- def data_sources=(hash)
72
- @data_sources = hash
73
- end
74
-
75
- def data_source(key)
76
- data_sources[key]
63
+ def log_response_code_error(error)
64
+ self.request_end_time = Time.now
65
+ benchmark_run.async.log(
66
+ e.response_code,
67
+ request_start_time,
68
+ request_end_time,
69
+ current_request_label,
70
+ current_request_threshold
71
+ )
77
72
  end
78
73
  end
79
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celluloid-benchmark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Willson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2014-01-09 00:00:00 Z
12
+ date: 2014-02-26 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: celluloid
@@ -58,6 +58,7 @@ files:
58
58
  - lib/celluloid_benchmark.rb
59
59
  - lib/celluloid_benchmark/benchmark.rb
60
60
  - lib/celluloid_benchmark/benchmark_run.rb
61
+ - lib/celluloid_benchmark/data_sources.rb
61
62
  - lib/celluloid_benchmark/runner.rb
62
63
  - lib/celluloid_benchmark/version.rb
63
64
  - lib/celluloid_benchmark/visitor.rb
@@ -84,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
85
  requirements: []
85
86
 
86
87
  rubyforge_project:
87
- rubygems_version: 2.2.1
88
+ rubygems_version: 2.2.2
88
89
  signing_key:
89
90
  specification_version: 4
90
91
  summary: Pure Ruby, realistic, website load test tool