apdex 0.2.0 → 0.3.0
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.
- data/CHANGES.markdown +4 -0
- data/VERSION.yml +2 -2
- data/lib/apdex.rb +1 -0
- data/lib/apdex/calculate.rb +34 -0
- data/lib/apdex/calculate_from_log.rb +1 -26
- data/spec/apdex/calculate_spec.rb +18 -0
- metadata +7 -5
data/CHANGES.markdown
CHANGED
data/VERSION.yml
CHANGED
data/lib/apdex.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Apdex
|
2
|
+
class Calculate
|
3
|
+
def call(threshold, times)
|
4
|
+
output = categorize_times(threshold, times)
|
5
|
+
output[:score] = calculate_apdex(output)
|
6
|
+
output
|
7
|
+
end
|
8
|
+
|
9
|
+
protected
|
10
|
+
|
11
|
+
def categorize_times(threshold, times)
|
12
|
+
output = {}
|
13
|
+
output[:satisfied] = output[:tolerating] = output[:frustrated] = 0
|
14
|
+
times.each do |value|
|
15
|
+
if value <= threshold
|
16
|
+
output[:satisfied] += 1
|
17
|
+
elsif value <= (threshold * 4)
|
18
|
+
output[:tolerating] += 1
|
19
|
+
else
|
20
|
+
output[:frustrated] += 1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
output
|
24
|
+
end
|
25
|
+
|
26
|
+
def calculate_apdex(output)
|
27
|
+
raw_score = (1.0 *
|
28
|
+
(output[:satisfied] + (output[:tolerating]/2.0)) /
|
29
|
+
(output[:satisfied] + output[:tolerating] + output[:frustrated])
|
30
|
+
)
|
31
|
+
("%0.3f" % raw_score).to_f
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -19,9 +19,7 @@ module Apdex
|
|
19
19
|
|
20
20
|
def call(threshold, input)
|
21
21
|
values = value_from_input(input)
|
22
|
-
|
23
|
-
output[:score] = calculate_apdex(output)
|
24
|
-
output
|
22
|
+
Calculate.new.call(threshold, values)
|
25
23
|
end
|
26
24
|
|
27
25
|
protected
|
@@ -37,28 +35,5 @@ module Apdex
|
|
37
35
|
end
|
38
36
|
end
|
39
37
|
end
|
40
|
-
|
41
|
-
def categorize_values(values, threshold)
|
42
|
-
output = {}
|
43
|
-
output[:satisfied] = output[:tolerating] = output[:frustrated] = 0
|
44
|
-
values.each do |value|
|
45
|
-
if value <= threshold
|
46
|
-
output[:satisfied] += 1
|
47
|
-
elsif value <= (threshold * 4)
|
48
|
-
output[:tolerating] += 1
|
49
|
-
else
|
50
|
-
output[:frustrated] += 1
|
51
|
-
end
|
52
|
-
end
|
53
|
-
output
|
54
|
-
end
|
55
|
-
|
56
|
-
def calculate_apdex(output)
|
57
|
-
raw_score = (1.0 *
|
58
|
-
(output[:satisfied] + (output[:tolerating]/2)) /
|
59
|
-
(output[:satisfied] + output[:tolerating] + output[:frustrated])
|
60
|
-
)
|
61
|
-
("%0.3f" % raw_score).to_f
|
62
|
-
end
|
63
38
|
end
|
64
39
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
|
2
|
+
|
3
|
+
module Apdex
|
4
|
+
describe Calculate do
|
5
|
+
describe "#call" do
|
6
|
+
context "when the sum of the tolerating counts is odd" do
|
7
|
+
it "calculates the correct score" do
|
8
|
+
Calculate.new.call(1, [2, 0.5]).should == {
|
9
|
+
:satisfied => 1,
|
10
|
+
:tolerating => 1,
|
11
|
+
:frustrated => 0,
|
12
|
+
:score => 0.75
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apdex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Woolley
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2009-
|
14
|
+
date: 2009-06-09 00:00:00 -07:00
|
15
15
|
default_executable: apdex_from_log
|
16
16
|
dependencies: []
|
17
17
|
|
@@ -30,8 +30,9 @@ files:
|
|
30
30
|
- VERSION.yml
|
31
31
|
- bin/apdex_from_log
|
32
32
|
- lib/apdex.rb
|
33
|
+
- lib/apdex/calculate.rb
|
33
34
|
- lib/apdex/calculate_from_log.rb
|
34
|
-
has_rdoc:
|
35
|
+
has_rdoc: false
|
35
36
|
homepage: http://github.com/pivotal/apdex
|
36
37
|
licenses: []
|
37
38
|
|
@@ -57,9 +58,10 @@ requirements: []
|
|
57
58
|
rubyforge_project:
|
58
59
|
rubygems_version: 1.3.5
|
59
60
|
signing_key:
|
60
|
-
specification_version:
|
61
|
+
specification_version: 3
|
61
62
|
summary: Calculate apdex scores from an Apache or Nginx log
|
62
63
|
test_files:
|
63
64
|
- spec/apdex/calculate_from_log_spec.rb
|
64
|
-
- spec/
|
65
|
+
- spec/apdex/calculate_spec.rb
|
65
66
|
- spec/spec_helper.rb
|
67
|
+
- spec/spec_suite.rb
|