celluloid-benchmark 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/celluloid-benchmark +2 -3
- data/lib/celluloid_benchmark/benchmark_run.rb +10 -9
- data/lib/celluloid_benchmark/runner.rb +20 -8
- data/lib/celluloid_benchmark/version.rb +1 -1
- metadata +2 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5053fec389c66821a970308a2a660788e0d2c63
|
4
|
+
data.tar.gz: 5bbcac6fff25c7465a179413b5a3a5f3db15ca98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1790062aba09ef03ec6e6f42dd95b9dc94b0eb38172869487aa9394d352c02c3d1881172aac099f70050d086194bd45d75276d1602143cc6caac0488362e2184
|
7
|
+
data.tar.gz: ff926c409d718b55a1f2edca1429fe3c59051b0cf4ffa48cca2c11963cbcffb060c73d9d47d83a868a8368cc775b6a6141e8a1614a26e3c4a48368042476150f
|
data/bin/celluloid-benchmark
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
3
|
require_relative "../lib/celluloid_benchmark"
|
4
|
-
require "os"
|
5
4
|
|
6
5
|
session_path = File.expand_path(ARGV[0])
|
7
6
|
|
@@ -10,11 +9,11 @@ if duration == 0
|
|
10
9
|
duration = 20
|
11
10
|
end
|
12
11
|
|
13
|
-
benchmark_run = CelluloidBenchmark::Runner.run session_path, duration,
|
12
|
+
benchmark_run = CelluloidBenchmark::Runner.run session_path, duration, ARGV[2] && ARGV[2].to_i
|
14
13
|
|
15
14
|
p benchmark_run
|
16
15
|
puts
|
17
|
-
p "#{benchmark_run.requests / benchmark_run.elapsed_time} requests per second. #{benchmark_run.requests} requests in #{benchmark_run.elapsed_time} seconds by #{
|
16
|
+
p "#{benchmark_run.requests / benchmark_run.elapsed_time} requests per second. #{benchmark_run.requests} requests in #{benchmark_run.elapsed_time} seconds by #{benchmark_run.visitors} visitors."
|
18
17
|
|
19
18
|
puts
|
20
19
|
benchmark_run.benchmarks.each do |trans|
|
@@ -11,13 +11,14 @@ module CelluloidBenchmark
|
|
11
11
|
attr_accessor :ended_at
|
12
12
|
attr_accessor :logger
|
13
13
|
attr_accessor :started_at
|
14
|
+
attr_accessor :visitors
|
14
15
|
attr_reader :thresholds
|
15
16
|
|
16
17
|
def initialize
|
17
18
|
if !Dir.exists?("log")
|
18
19
|
FileUtils.mkdir "log"
|
19
20
|
end
|
20
|
-
|
21
|
+
|
21
22
|
# Could replace with Celluloid.logger
|
22
23
|
@logger = ::Logger.new("log/benchmark.log")
|
23
24
|
@thresholds = Hash.new
|
@@ -27,11 +28,11 @@ module CelluloidBenchmark
|
|
27
28
|
time = end_time - start_time
|
28
29
|
response_times[label] << time
|
29
30
|
response_codes[label] << http_status_code.to_i
|
30
|
-
|
31
|
+
|
31
32
|
if threshold
|
32
33
|
thresholds[label] = threshold
|
33
34
|
end
|
34
|
-
|
35
|
+
|
35
36
|
logger.info "#{http_status_code} #{time} #{label}"
|
36
37
|
end
|
37
38
|
|
@@ -42,25 +43,25 @@ module CelluloidBenchmark
|
|
42
43
|
def response_codes
|
43
44
|
@response_codes ||= Hash.new { |hash, value| hash[value] = [] }
|
44
45
|
end
|
45
|
-
|
46
|
+
|
46
47
|
def requests
|
47
48
|
response_times.values.compact.map(&:size).reduce(0, &:+)
|
48
49
|
end
|
49
|
-
|
50
|
+
|
50
51
|
def benchmarks
|
51
52
|
response_times.map do |label, response_times|
|
52
53
|
CelluloidBenchmark::Benchmark.new label, thresholds[label], response_times, response_codes[label]
|
53
54
|
end
|
54
55
|
end
|
55
|
-
|
56
|
+
|
56
57
|
def mark_start
|
57
58
|
@started_at = Time.now
|
58
59
|
end
|
59
|
-
|
60
|
+
|
60
61
|
def mark_end
|
61
62
|
@ended_at = Time.now
|
62
63
|
end
|
63
|
-
|
64
|
+
|
64
65
|
def elapsed_time
|
65
66
|
if started_at && ended_at
|
66
67
|
(ended_at - started_at).to_f
|
@@ -68,7 +69,7 @@ module CelluloidBenchmark
|
|
68
69
|
0
|
69
70
|
end
|
70
71
|
end
|
71
|
-
|
72
|
+
|
72
73
|
def ok?
|
73
74
|
benchmarks.all?(&:ok?)
|
74
75
|
end
|
@@ -7,37 +7,49 @@ Celluloid.logger = nil
|
|
7
7
|
module CelluloidBenchmark
|
8
8
|
# Run a scenario in several Visitors and return a BenchmarkRun
|
9
9
|
class Runner
|
10
|
-
def self.run(session_path, duration =
|
10
|
+
def self.run(session_path, duration = 20, visitors = nil)
|
11
11
|
raise("session_path is required") unless session_path
|
12
12
|
raise("'#{session_path}' does not exist") unless File.exists?(session_path)
|
13
13
|
|
14
14
|
require session_path
|
15
15
|
|
16
16
|
VisitorGroup.run!
|
17
|
-
|
17
|
+
set_visitor_pool_size visitors
|
18
|
+
visitors = visitors_count(visitors)
|
19
|
+
|
18
20
|
benchmark_run = Celluloid::Actor[:benchmark_run]
|
21
|
+
benchmark_run.visitors = visitors
|
19
22
|
|
20
23
|
benchmark_run.mark_start
|
21
|
-
futures = run_sessions(benchmark_run, duration)
|
24
|
+
futures = run_sessions(benchmark_run, duration, visitors)
|
22
25
|
futures.map(&:value)
|
23
26
|
benchmark_run.mark_end
|
24
27
|
|
25
28
|
benchmark_run
|
26
29
|
end
|
27
30
|
|
28
|
-
def self.run_sessions(benchmark_run, duration)
|
29
|
-
|
31
|
+
def self.run_sessions(benchmark_run, duration, visitors)
|
32
|
+
pool = Celluloid::Actor[:visitor_pool]
|
30
33
|
futures = []
|
31
|
-
|
32
|
-
futures <<
|
34
|
+
visitors.times do
|
35
|
+
futures << pool.future.run_session(benchmark_run, duration)
|
33
36
|
end
|
34
37
|
futures
|
35
38
|
end
|
36
39
|
|
37
|
-
def self.
|
40
|
+
def self.set_visitor_pool_size(size)
|
38
41
|
if size && size.to_i > 0
|
39
42
|
Visitor.pool.size = size.to_i + 2
|
40
43
|
end
|
41
44
|
end
|
45
|
+
|
46
|
+
def self.visitors_count(count)
|
47
|
+
count = count || (Visitor.pool.size - 2)
|
48
|
+
if count > 1
|
49
|
+
count
|
50
|
+
else
|
51
|
+
1
|
52
|
+
end
|
53
|
+
end
|
42
54
|
end
|
43
55
|
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.1.
|
4
|
+
version: 0.1.5
|
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-06-
|
12
|
+
date: 2014-06-19 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: celluloid
|
@@ -62,14 +62,6 @@ dependencies:
|
|
62
62
|
version: "1.25"
|
63
63
|
type: :runtime
|
64
64
|
version_requirements: *id005
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: os
|
67
|
-
prerelease: false
|
68
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
69
|
-
requirements:
|
70
|
-
- *id006
|
71
|
-
type: :runtime
|
72
|
-
version_requirements: *id007
|
73
65
|
description: |-
|
74
66
|
Celluloid Benchmark realistically load tests websites. Write expressive, concise load tests in Ruby. Use Rubinius and Celluloid
|
75
67
|
forpec high concurrency. Use Mechanize for a realistic (albeit non-JavaScript) browser client.
|