apdex 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,6 @@
1
+ - Added Apdex::Calculate
2
+ - Fixed floating point division issue when there is an odd number of tolerations (caused incorrect score)
3
+
4
+ 0.2.0
1
5
  - Initial Release
2
6
  - Added Apdex::CalculateFromLog
@@ -1,4 +1,4 @@
1
1
  ---
2
- :major: 0
3
- :minor: 2
2
+ :minor: 3
4
3
  :patch: 0
4
+ :major: 0
@@ -2,4 +2,5 @@ module Apdex
2
2
  end
3
3
 
4
4
  dir = File.dirname(__FILE__)
5
+ require "#{dir}/apdex/calculate"
5
6
  require "#{dir}/apdex/calculate_from_log"
@@ -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
- output = categorize_values(values, threshold)
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.2.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-04-25 00:00:00 -07:00
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: true
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: 2
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/spec_suite.rb
65
+ - spec/apdex/calculate_spec.rb
65
66
  - spec/spec_helper.rb
67
+ - spec/spec_suite.rb