evt-diagnostics-sample 0.1.2.0 → 0.2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/diagnostics/sample/controls.rb +4 -0
- data/lib/diagnostics/sample/controls/frequency.rb +19 -0
- data/lib/diagnostics/sample/controls/mean.rb +19 -0
- data/lib/diagnostics/sample/controls/result.rb +35 -0
- data/lib/diagnostics/sample/controls/standard_deviation.rb +20 -4
- data/lib/diagnostics/sample/measure.rb +3 -3
- data/lib/diagnostics/sample/result.rb +13 -2
- data/lib/diagnostics/sample/sample.rb +10 -2
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b85388ac039ba0e556809c31e671596ccf18f8f22c906e03ab2d1a024d1543e4
|
4
|
+
data.tar.gz: 8b59915f3a766aa2bcf19f4c6c5f7ef41d6263c4c3909bcd027868a100cce6da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad0d0ec1d27171db800c8f433017bd73ee321b3ed03a770ee956f8177152a8fbc008f7b9528a2fb55760c6402433871f55cd5ad6d27ea30e7a045238b443773f
|
7
|
+
data.tar.gz: 3efe0d3c1cb7927498b6922b7aa1da240be5c8bc24966ced2ac3f5ce1829e88b76cf22355ad75b994aaa8473ffe9e7db11fb00774940b873af0e09ba42c56c86
|
@@ -3,4 +3,8 @@ require 'clock/controls'
|
|
3
3
|
require 'diagnostics/sample/controls/clock'
|
4
4
|
require 'diagnostics/sample/controls/time'
|
5
5
|
|
6
|
+
require 'diagnostics/sample/controls/frequency'
|
7
|
+
require 'diagnostics/sample/controls/mean'
|
6
8
|
require 'diagnostics/sample/controls/standard_deviation'
|
9
|
+
|
10
|
+
require 'diagnostics/sample/controls/result'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Diagnostics
|
2
|
+
class Sample
|
3
|
+
module Controls
|
4
|
+
module Frequency
|
5
|
+
module Values
|
6
|
+
def self.milliseconds
|
7
|
+
Mean::Values.example
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Result
|
12
|
+
def self.example
|
13
|
+
1_000 / Mean::Result.example
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Diagnostics
|
2
|
+
class Sample
|
3
|
+
module Controls
|
4
|
+
module Result
|
5
|
+
def self.example
|
6
|
+
result = Sample::Result.new
|
7
|
+
|
8
|
+
StandardDeviation::Values.example.each do |value|
|
9
|
+
result.cycle(value)
|
10
|
+
end
|
11
|
+
|
12
|
+
result
|
13
|
+
end
|
14
|
+
|
15
|
+
module Digest
|
16
|
+
def self.example
|
17
|
+
values = [
|
18
|
+
StandardDeviation::Values.sum,
|
19
|
+
StandardDeviation::Values.mean,
|
20
|
+
StandardDeviation::Values.frequency,
|
21
|
+
StandardDeviation::Result.example
|
22
|
+
]
|
23
|
+
|
24
|
+
<<~TEXT % values
|
25
|
+
Cycle Time: %fms
|
26
|
+
Mean Cycle Time: %fms
|
27
|
+
Cycles Per Second: %f
|
28
|
+
Cycle Time Standard Deviation: %fms
|
29
|
+
TEXT
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -3,12 +3,28 @@ module Diagnostics
|
|
3
3
|
module Controls
|
4
4
|
module StandardDeviation
|
5
5
|
# Source: https://en.wikipedia.org/wiki/Standard_deviation#Population_standard_deviation_of_grades_of_eight_students (Nathan Ladd, Wed 30 May 2018)
|
6
|
-
|
7
|
-
|
6
|
+
module Values
|
7
|
+
def self.example
|
8
|
+
[2, 4, 4, 4, 5, 5, 7, 9]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.sum
|
12
|
+
40
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.mean
|
16
|
+
5
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.frequency
|
20
|
+
200
|
21
|
+
end
|
8
22
|
end
|
9
23
|
|
10
|
-
|
11
|
-
|
24
|
+
module Result
|
25
|
+
def self.example
|
26
|
+
2
|
27
|
+
end
|
12
28
|
end
|
13
29
|
end
|
14
30
|
end
|
@@ -47,11 +47,11 @@ module Diagnostics
|
|
47
47
|
|
48
48
|
::GC.enable unless gc
|
49
49
|
|
50
|
-
|
50
|
+
elapsed_time_nanoseconds = end_time - start_time
|
51
51
|
|
52
|
-
logger.trace { "Action measured (GC: #{gc.inspect}, Elapsed Time: #{LogText.elapsed_time_milliseconds(
|
52
|
+
logger.trace { "Action measured (GC: #{gc.inspect}, Elapsed Time: #{LogText.elapsed_time_milliseconds(elapsed_time_nanoseconds)})" }
|
53
53
|
|
54
|
-
|
54
|
+
elapsed_time_nanoseconds
|
55
55
|
end
|
56
56
|
|
57
57
|
module LogText
|
@@ -23,7 +23,7 @@ module Diagnostics
|
|
23
23
|
cycle_time_milliseconds / cycles
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def cycles_per_second
|
27
27
|
cycles / (cycle_time_milliseconds / 1_000)
|
28
28
|
end
|
29
29
|
|
@@ -32,6 +32,7 @@ module Diagnostics
|
|
32
32
|
|
33
33
|
Math.sqrt(variance)
|
34
34
|
end
|
35
|
+
alias_method :standard_deviation, :cycle_time_standard_deviation
|
35
36
|
|
36
37
|
def warmup_cycle(elapsed_time)
|
37
38
|
self.warmup_cycle_time_milliseconds += elapsed_time
|
@@ -45,7 +46,7 @@ module Diagnostics
|
|
45
46
|
warmup_cycle_time_milliseconds / warmup_cycles
|
46
47
|
end
|
47
48
|
|
48
|
-
def
|
49
|
+
def warmup_cycles_per_second
|
49
50
|
warmup_cycles / (warmup_cycle_time_milliseconds / 1_000)
|
50
51
|
end
|
51
52
|
|
@@ -54,6 +55,16 @@ module Diagnostics
|
|
54
55
|
|
55
56
|
Math.sqrt(variance)
|
56
57
|
end
|
58
|
+
|
59
|
+
def digest
|
60
|
+
<<~TEXT % [cycle_time_milliseconds, mean_cycle_time_milliseconds, cycles_per_second, cycle_time_standard_deviation]
|
61
|
+
Cycle Time: %fms
|
62
|
+
Mean Cycle Time: %fms
|
63
|
+
Cycles Per Second: %f
|
64
|
+
Cycle Time Standard Deviation: %fms
|
65
|
+
TEXT
|
66
|
+
end
|
67
|
+
alias_method :to_s, :digest
|
57
68
|
end
|
58
69
|
end
|
59
70
|
end
|
@@ -41,7 +41,9 @@ module Diagnostics
|
|
41
41
|
logger.trace { "Starting warmup (Warmup Cycles: #{warmup_cycles})" }
|
42
42
|
|
43
43
|
warmup_cycles.times do
|
44
|
-
|
44
|
+
elapsed_time_nanoseconds = measure.()
|
45
|
+
|
46
|
+
elapsed_time = milliseconds(elapsed_time_nanoseconds)
|
45
47
|
|
46
48
|
result.warmup_cycle(elapsed_time)
|
47
49
|
end
|
@@ -51,7 +53,9 @@ module Diagnostics
|
|
51
53
|
logger.trace { "Starting sample (Cycles: #{cycles}, Warmup Cycles: #{warmup_cycles})" }
|
52
54
|
|
53
55
|
cycles.times do
|
54
|
-
|
56
|
+
elapsed_time_nanoseconds = measure.()
|
57
|
+
|
58
|
+
elapsed_time = milliseconds(elapsed_time_nanoseconds)
|
55
59
|
|
56
60
|
result.cycle(elapsed_time)
|
57
61
|
end
|
@@ -60,5 +64,9 @@ module Diagnostics
|
|
60
64
|
|
61
65
|
result
|
62
66
|
end
|
67
|
+
|
68
|
+
def milliseconds(nanoseconds)
|
69
|
+
Rational(nanoseconds, 1_000_000)
|
70
|
+
end
|
63
71
|
end
|
64
72
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-diagnostics-sample
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
@@ -75,6 +75,9 @@ files:
|
|
75
75
|
- lib/diagnostics/sample.rb
|
76
76
|
- lib/diagnostics/sample/controls.rb
|
77
77
|
- lib/diagnostics/sample/controls/clock.rb
|
78
|
+
- lib/diagnostics/sample/controls/frequency.rb
|
79
|
+
- lib/diagnostics/sample/controls/mean.rb
|
80
|
+
- lib/diagnostics/sample/controls/result.rb
|
78
81
|
- lib/diagnostics/sample/controls/standard_deviation.rb
|
79
82
|
- lib/diagnostics/sample/controls/time.rb
|
80
83
|
- lib/diagnostics/sample/defaults.rb
|