ritsudo 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/ritsudo/cli.rb +2 -1
- data/lib/ritsudo/collector.rb +5 -5
- data/lib/ritsudo/result/helper.rb +26 -0
- data/lib/ritsudo/result/misc.rb +20 -8
- data/lib/ritsudo/result/uncompletable.rb +28 -13
- data/lib/ritsudo/version.rb +1 -1
- data/lib/ritsudo.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a77d5c59f6d7b99726077b003de30cd23f39592f28468db7d026d957e4cfd48a
|
4
|
+
data.tar.gz: 83c34af615e1fc84fe88f05ada1ba81fcf4d842f8579f9f17bb23c766e146349
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03b861dd1a4d7b1b4c571f6c69a62b513863e307bfd922be35271151ba06b9910284d8162ee8b031ee409e35ba072eefe067236eafd0a842e60ed12b652a7fb2
|
7
|
+
data.tar.gz: 10d8668f416cbc181ab5bdbe9e2b7b82c0b3af771eff400bcff04c993bd0955a30cddfaf00d942f5e9f4acf781022b20717c0dfead6ea009a6d013c810ce4501
|
data/README.md
CHANGED
@@ -71,6 +71,13 @@ Ritsudo requests 5 times: https://example.com
|
|
71
71
|
ritsudo -a https://example.com/page -m "example.com" -C "hoge=fuga"
|
72
72
|
```
|
73
73
|
|
74
|
+
### Remove outlier
|
75
|
+
-r option removes outliders outside of (stdev * numeric) value.
|
76
|
+
```
|
77
|
+
ritsudo -a https://example.com/page -m "example.com" -s #{numeric}
|
78
|
+
```
|
79
|
+
|
80
|
+
|
74
81
|
#### Problem
|
75
82
|
Headless chrome doesn't support to set cookies before access.
|
76
83
|
So, Ritsudo accesses root path(e.g https://example.com) before each benchmark.
|
data/lib/ritsudo/cli.rb
CHANGED
@@ -11,6 +11,7 @@ module Ritsudo
|
|
11
11
|
class_option :wait_time, default: 1, type: :numeric, aliases: ['-w']
|
12
12
|
class_option :ua, type: :string, aliases: ['-u']
|
13
13
|
class_option :match, type: :string, aliases: ['-m']
|
14
|
+
class_option :outliters_stdev_multiple, type: :numeric, aliases: ['-r']
|
14
15
|
|
15
16
|
desc "benchmark URL", "benchmark"
|
16
17
|
def benchmark()
|
@@ -27,7 +28,7 @@ module Ritsudo
|
|
27
28
|
cookies: options[:cookies]
|
28
29
|
}
|
29
30
|
)
|
30
|
-
benchmark.collector.report
|
31
|
+
benchmark.collector.report(outliters_stdev_multiple: options[:outliters_stdev_multiple])
|
31
32
|
end
|
32
33
|
tasks["benchmark"].options = self.class_options
|
33
34
|
end
|
data/lib/ritsudo/collector.rb
CHANGED
@@ -33,14 +33,14 @@ module Ritsudo
|
|
33
33
|
@misc.add(group, name, value)
|
34
34
|
end
|
35
35
|
|
36
|
-
def report
|
37
|
-
@misc.report
|
36
|
+
def report(outliters_stdev_multiple: nil)
|
37
|
+
@misc.report(outliters_stdev_multiple: outliters_stdev_multiple)
|
38
38
|
puts ""
|
39
|
-
@documents.report
|
39
|
+
@documents.report(outliters_stdev_multiple: outliters_stdev_multiple)
|
40
40
|
puts ""
|
41
|
-
@xhrs.report
|
41
|
+
@xhrs.report(outliters_stdev_multiple: outliters_stdev_multiple)
|
42
42
|
puts ""
|
43
|
-
@scripts.report
|
43
|
+
@scripts.report(outliters_stdev_multiple: outliters_stdev_multiple)
|
44
44
|
puts ""
|
45
45
|
end
|
46
46
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Ritsudo
|
2
|
+
module Result
|
3
|
+
module Helper
|
4
|
+
def self.remove_outliters(values, stdev_multiple)
|
5
|
+
stdev = standard_deviation(values)
|
6
|
+
mean = mean(values)
|
7
|
+
range = (mean - (stdev * stdev_multiple))..(mean + (stdev * stdev_multiple))
|
8
|
+
values.select { |v| range.cover?(v) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.mean(values)
|
12
|
+
sum = values.sum(0.0)
|
13
|
+
mean = sum / values.size
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.variance(values)
|
17
|
+
total = values.inject(0) { |sum, v| sum + ((v - mean(values)) ** 2) }
|
18
|
+
total.to_f / (values.size - 1)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.standard_deviation(values)
|
22
|
+
Math.sqrt(variance(values))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/ritsudo/result/misc.rb
CHANGED
@@ -11,20 +11,32 @@ module Ritsudo
|
|
11
11
|
@misc[group][name] << value
|
12
12
|
end
|
13
13
|
|
14
|
-
def report
|
14
|
+
def report(outliters_stdev_multiple: nil)
|
15
15
|
table_data = []
|
16
16
|
@misc.each do |group, name_and_values|
|
17
17
|
puts "[#{group}]"
|
18
|
-
|
19
|
-
|
18
|
+
|
19
|
+
name_and_values.each do |name, all_values|
|
20
|
+
use_remove_outsiders = outliters_stdev_multiple && all_values.size > 1
|
21
|
+
if use_remove_outsiders
|
22
|
+
values = Ritsudo::Result::Helper.remove_outliters(all_values, outliters_stdev_multiple)
|
23
|
+
else
|
24
|
+
values = all_values
|
25
|
+
end
|
26
|
+
|
27
|
+
result = {
|
20
28
|
name: name,
|
21
|
-
avg: (values.sum(0.0) / values.length)
|
22
|
-
max: values.max
|
23
|
-
min: values.min
|
24
|
-
count: values.size
|
29
|
+
avg: (values.sum(0.0) / values.length)&.round(2),
|
30
|
+
max: values.max&.round(2),
|
31
|
+
min: values.min&.round(2),
|
32
|
+
count: values.size,
|
33
|
+
outsiders: all_values.size - values.size
|
25
34
|
}
|
35
|
+
|
36
|
+
|
37
|
+
table_data << result
|
26
38
|
end
|
27
|
-
Formatador.display_table(table_data, [:name, :avg, :max, :min, :count])
|
39
|
+
Formatador.display_table(table_data, [:name, :avg, :max, :min, :count, :outsiders])
|
28
40
|
end
|
29
41
|
end
|
30
42
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Ritsudo
|
2
2
|
module Result
|
3
3
|
module Uncompletable
|
4
|
+
include Ritsudo::Result::Helper
|
5
|
+
|
4
6
|
def add(request)
|
5
7
|
@requests ||= []
|
6
8
|
@uncompleted ||= Hash.new
|
@@ -17,29 +19,42 @@ module Ritsudo
|
|
17
19
|
raise NotImplementedError
|
18
20
|
end
|
19
21
|
|
20
|
-
def report
|
22
|
+
def report(outliters_stdev_multiple: nil)
|
21
23
|
puts "[#{name}]"
|
22
24
|
table_data = []
|
23
25
|
(@requests || []).uniq.each do |url|
|
24
26
|
if @completed[url] && !@completed[url].empty?
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
all_request_times = @completed[url]
|
28
|
+
use_remove_outliters = outliters_stdev_multiple && all_request_times.size > 1
|
29
|
+
|
30
|
+
if use_remove_outliters
|
31
|
+
request_times = Ritsudo::Result::Helper.remove_outliters(all_request_times, outliters_stdev_multiple)
|
32
|
+
else
|
33
|
+
request_times = all_request_times
|
34
|
+
end
|
35
|
+
|
36
|
+
avg = (request_times.sum(0.0) / request_times.length)&.round(2)
|
37
|
+
max = request_times.max&.round(2)
|
38
|
+
min = request_times.min&.round(2)
|
39
|
+
count = request_times.size
|
29
40
|
else
|
30
41
|
avg = max = min = count = "-"
|
31
42
|
end
|
32
43
|
|
33
|
-
|
34
|
-
url:
|
35
|
-
avg:
|
36
|
-
max:
|
37
|
-
min:
|
38
|
-
count:
|
39
|
-
uncompleted: @uncompleted[url]
|
44
|
+
result = {
|
45
|
+
url: url[0..100],
|
46
|
+
avg: avg,
|
47
|
+
max: max,
|
48
|
+
min: min,
|
49
|
+
count: count,
|
50
|
+
uncompleted: @uncompleted[url],
|
51
|
+
outliters: all_request_times.size - request_times.size
|
40
52
|
}
|
53
|
+
|
54
|
+
|
55
|
+
table_data << result
|
41
56
|
end
|
42
|
-
Formatador.display_table(table_data, [:url, :avg, :max, :min, :count, :uncompleted])
|
57
|
+
Formatador.display_table(table_data, [:url, :avg, :max, :min, :count, :uncompleted, :outliters])
|
43
58
|
end
|
44
59
|
end
|
45
60
|
end
|
data/lib/ritsudo/version.rb
CHANGED
data/lib/ritsudo.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ritsudo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shingo morita
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/ritsudo/result.rb
|
147
147
|
- lib/ritsudo/result/base.rb
|
148
148
|
- lib/ritsudo/result/documents.rb
|
149
|
+
- lib/ritsudo/result/helper.rb
|
149
150
|
- lib/ritsudo/result/misc.rb
|
150
151
|
- lib/ritsudo/result/scripts.rb
|
151
152
|
- lib/ritsudo/result/uncompletable.rb
|