diagnosticism 0.0.0 → 0.1.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.
- checksums.yaml +4 -4
- data/lib/diagnosticism/doomgram.rb +275 -0
- data/lib/diagnosticism/version.rb +3 -2
- data/test/unit/tc_doomgram.rb +377 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 803e203f2fdc8ac63b75c535353f4c9b431ad8b529dba37078433fc1a2cf2028
|
4
|
+
data.tar.gz: 1084d060bf839c43a048805398bb50df83bf615862750cc996a3ecfb80e92b4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 759b4271d1d41331a9629c53302c90f643913812484647bf7a7d581900c83412c41f0fe75b6a20bd973394a6e6ed6f459d9a4d57966599181f2e316761c217d5
|
7
|
+
data.tar.gz: b87704039b1c16acbcf6955075254fee69aa649449106b5b9c8bb94d2ed960655dcf7ae63896b0723df29624566222f395cd94384a0601b59ab4c72f2710e5c8
|
@@ -0,0 +1,275 @@
|
|
1
|
+
# ######################################################################## #
|
2
|
+
# File: doomgram.rb
|
3
|
+
#
|
4
|
+
# Purpose: Definition of the `DOOMGram` class.
|
5
|
+
#
|
6
|
+
# Created: 9th January 2025
|
7
|
+
# Updated: 9th January 2025
|
8
|
+
#
|
9
|
+
# Author: Matthew Wilson
|
10
|
+
#
|
11
|
+
# Copyright (c) 2025, Matthew Wilson and Synesis Information Systems
|
12
|
+
# All rights reserved.
|
13
|
+
#
|
14
|
+
# Redistribution and use in source and binary forms, with or without
|
15
|
+
# modification, are permitted provided that the following conditions are met:
|
16
|
+
#
|
17
|
+
# * Redistributions of source code must retain the above copyright notice,
|
18
|
+
# this list of conditions and the following disclaimer.
|
19
|
+
#
|
20
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
21
|
+
# this list of conditions and the following disclaimer in the documentation
|
22
|
+
# and/or other materials provided with the distribution.
|
23
|
+
#
|
24
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
25
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
26
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
27
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
28
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
29
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
30
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
31
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
32
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
33
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
34
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
35
|
+
#
|
36
|
+
# ######################################################################## #
|
37
|
+
|
38
|
+
|
39
|
+
=begin
|
40
|
+
=end
|
41
|
+
|
42
|
+
module Diagnosticism
|
43
|
+
|
44
|
+
# Decimal Order-Of-Magnitude frequency histoGRAM
|
45
|
+
class DOOMGram
|
46
|
+
|
47
|
+
def initialize
|
48
|
+
|
49
|
+
@event_count = 0
|
50
|
+
|
51
|
+
@total_event_time_ns = 0
|
52
|
+
|
53
|
+
@min_event_time_ns = nil
|
54
|
+
@max_event_time_ns = nil
|
55
|
+
|
56
|
+
@num_events_in_1ns = 0
|
57
|
+
@num_events_in_10ns = 0
|
58
|
+
@num_events_in_100ns = 0
|
59
|
+
@num_events_in_1us = 0
|
60
|
+
@num_events_in_10us = 0
|
61
|
+
@num_events_in_100us = 0
|
62
|
+
@num_events_in_1ms = 0
|
63
|
+
@num_events_in_10ms = 0
|
64
|
+
@num_events_in_100ms = 0
|
65
|
+
@num_events_in_1s = 0
|
66
|
+
@num_events_in_10s = 0
|
67
|
+
@num_events_ge_100s = 0
|
68
|
+
end # initialize()
|
69
|
+
|
70
|
+
# Number of events counted
|
71
|
+
attr_reader :event_count
|
72
|
+
# Obtains the total event time (in nanoseconds)
|
73
|
+
attr_reader :total_event_time_ns
|
74
|
+
# Obtain the minimum event time (in nanoseconds), or +nil+ if no events
|
75
|
+
attr_reader :min_event_time_ns
|
76
|
+
# Obtain the maximum event time (in nanoseconds), or +nil+ if no events
|
77
|
+
attr_reader :max_event_time_ns
|
78
|
+
# Number of events counted in the interval [1ns, 10ns)
|
79
|
+
attr_reader :num_events_in_1ns
|
80
|
+
# Number of events counted in the interval [10ns, 100ns)
|
81
|
+
attr_reader :num_events_in_10ns
|
82
|
+
# Number of events counted in the interval [100ns, 1µs)
|
83
|
+
attr_reader :num_events_in_100ns
|
84
|
+
# Number of events counted in the interval [1µs, 10µs)
|
85
|
+
attr_reader :num_events_in_1us
|
86
|
+
# Number of events counted in the interval [10µs, 100µs)
|
87
|
+
attr_reader :num_events_in_10us
|
88
|
+
# Number of events counted in the interval [100µs, 1ms)
|
89
|
+
attr_reader :num_events_in_100us
|
90
|
+
# Number of events counted in the interval [1ms, 10ms)
|
91
|
+
attr_reader :num_events_in_1ms
|
92
|
+
# Number of events counted in the interval [10ms, 100ms)
|
93
|
+
attr_reader :num_events_in_10ms
|
94
|
+
# Number of events counted in the interval [100ms, 1s)
|
95
|
+
attr_reader :num_events_in_100ms
|
96
|
+
# Number of events counted in the interval [1s, 10s)
|
97
|
+
attr_reader :num_events_in_1s
|
98
|
+
# Number of events counted in the interval [10s, 100s)
|
99
|
+
attr_reader :num_events_in_10s
|
100
|
+
# Number of events counted in the interval [100s, ∞)
|
101
|
+
attr_reader :num_events_ge_100s
|
102
|
+
|
103
|
+
# Pushes an event with the given number of nanoseconds
|
104
|
+
def push_event_time_ns(time_in_ns)
|
105
|
+
|
106
|
+
@event_count += 1
|
107
|
+
|
108
|
+
@total_event_time_ns += time_in_ns
|
109
|
+
|
110
|
+
|
111
|
+
if @min_event_time_ns.nil? || time_in_ns < @min_event_time_ns
|
112
|
+
|
113
|
+
@min_event_time_ns = time_in_ns
|
114
|
+
end
|
115
|
+
|
116
|
+
if @max_event_time_ns.nil? || @max_event_time_ns < time_in_ns
|
117
|
+
|
118
|
+
@max_event_time_ns = time_in_ns
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
if time_in_ns >= 100_000_000
|
123
|
+
|
124
|
+
if time_in_ns >= 10_000_000_000
|
125
|
+
|
126
|
+
if time_in_ns >= 100_000_000_000
|
127
|
+
|
128
|
+
@num_events_ge_100s += 1
|
129
|
+
else
|
130
|
+
|
131
|
+
@num_events_in_10s += 1
|
132
|
+
end
|
133
|
+
else
|
134
|
+
|
135
|
+
if time_in_ns >= 1_000_000_000
|
136
|
+
|
137
|
+
@num_events_in_1s += 1
|
138
|
+
else
|
139
|
+
|
140
|
+
@num_events_in_100ms += 1
|
141
|
+
end
|
142
|
+
end
|
143
|
+
else
|
144
|
+
|
145
|
+
if time_in_ns >= 10_000
|
146
|
+
|
147
|
+
if time_in_ns >= 1_000_000
|
148
|
+
|
149
|
+
if time_in_ns >= 10_000_000
|
150
|
+
|
151
|
+
@num_events_in_10ms += 1
|
152
|
+
else
|
153
|
+
|
154
|
+
@num_events_in_1ms += 1
|
155
|
+
end
|
156
|
+
else
|
157
|
+
|
158
|
+
if time_in_ns >= 100_000
|
159
|
+
|
160
|
+
@num_events_in_100us += 1
|
161
|
+
else
|
162
|
+
|
163
|
+
@num_events_in_10us += 1
|
164
|
+
end
|
165
|
+
end
|
166
|
+
else
|
167
|
+
|
168
|
+
if time_in_ns >= 100
|
169
|
+
|
170
|
+
if time_in_ns >= 1_000
|
171
|
+
|
172
|
+
@num_events_in_1us += 1
|
173
|
+
else
|
174
|
+
|
175
|
+
@num_events_in_100ns += 1
|
176
|
+
end
|
177
|
+
else
|
178
|
+
|
179
|
+
if time_in_ns >= 10
|
180
|
+
|
181
|
+
@num_events_in_10ns += 1
|
182
|
+
elsif time_in_ns >= 1
|
183
|
+
|
184
|
+
@num_events_in_1ns += 1
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# Pushes an event with the given number of microseconds
|
192
|
+
def push_event_time_us(time_in_us)
|
193
|
+
|
194
|
+
push_event_time_ns time_in_us * 1_000
|
195
|
+
end
|
196
|
+
|
197
|
+
# Pushes an event with the given number of milliseconds
|
198
|
+
def push_event_time_ms(time_in_ms)
|
199
|
+
|
200
|
+
push_event_time_ns time_in_ms * 1_000_000
|
201
|
+
end
|
202
|
+
|
203
|
+
# Pushes an event with the given number of seconds
|
204
|
+
def push_event_time_s(time_in_s)
|
205
|
+
|
206
|
+
push_event_time_ns time_in_s * 1_000_000_000
|
207
|
+
end
|
208
|
+
|
209
|
+
# Converts to string form according to given options
|
210
|
+
#
|
211
|
+
# === Signature
|
212
|
+
#
|
213
|
+
# * *Parameters:*
|
214
|
+
# - +options+ (+Hash+, +Integer+) Combination of flags (with behaviour as described below for the +flags+ option), or an options hash;
|
215
|
+
#
|
216
|
+
# * *Options:*
|
217
|
+
# - +overflow_character+ (+String+) A string (of length 1) that specifies the symbol for counts outside the available range. Defaults to +'*'+;
|
218
|
+
# - +range+ (+String+) A string whose characters specificy the symbols to use for counts in orders of magnitude. Defaults to +'abcdefghijklmnopqrstuvwxyz'+, which caters to the counts 1-9 => +'a', 10-99 => +'b'+, 100-999 => +'c'+, ... 10^25-(10^26-1) => +'z'+;
|
219
|
+
# - +zero_character+ (+String+) A string (of length 1) that specifies the symbol for a count of 0. Defaults to +' '+;
|
220
|
+
#
|
221
|
+
# === Return
|
222
|
+
# (+String+) A string (of length 12) containing symbols representing the counts in the ranges 1ns, 10ns, ..., 10s, 100+s.
|
223
|
+
def to_strip **options
|
224
|
+
|
225
|
+
ch_zero = options[:zero_character] || options[:zero_char] || '_'
|
226
|
+
ch_overflow = options[:overflow_character] || options[:overflow_char] || '*'
|
227
|
+
range_chars = options[:range] || 'abcdefghijklmnopqrstuvwxyz'
|
228
|
+
|
229
|
+
counts = [
|
230
|
+
num_events_in_1ns,
|
231
|
+
num_events_in_10ns,
|
232
|
+
num_events_in_100ns,
|
233
|
+
num_events_in_1us,
|
234
|
+
num_events_in_10us,
|
235
|
+
num_events_in_100us,
|
236
|
+
num_events_in_1ms,
|
237
|
+
num_events_in_10ms,
|
238
|
+
num_events_in_100ms,
|
239
|
+
num_events_in_1s,
|
240
|
+
num_events_in_10s,
|
241
|
+
num_events_ge_100s,
|
242
|
+
]
|
243
|
+
|
244
|
+
s = ch_zero[0] * 12 # "____________"
|
245
|
+
|
246
|
+
counts.each_with_index do |count, index|
|
247
|
+
|
248
|
+
next if 0 == count
|
249
|
+
|
250
|
+
# TODO: get a faster way to count digits
|
251
|
+
oom = Math.log10(count).to_i
|
252
|
+
|
253
|
+
if oom < range_chars.size
|
254
|
+
|
255
|
+
s[index] = range_chars[oom]
|
256
|
+
else
|
257
|
+
|
258
|
+
s[index] = ch_overflow[0]
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
s
|
263
|
+
end
|
264
|
+
|
265
|
+
# Converts to string form according to default options
|
266
|
+
def to_s
|
267
|
+
|
268
|
+
to_strip
|
269
|
+
end
|
270
|
+
end # class DOOMGram
|
271
|
+
end # module Diagnosticism
|
272
|
+
|
273
|
+
|
274
|
+
# ############################## end of file ############################# #
|
275
|
+
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Purpose: Version for Diagnosticism.Ruby library
|
6
6
|
#
|
7
7
|
# Created: 3rd January 2025
|
8
|
-
# Updated:
|
8
|
+
# Updated: 9th January 2025
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/Diagnosticism.Ruby
|
11
11
|
#
|
@@ -50,7 +50,7 @@
|
|
50
50
|
module Diagnosticism
|
51
51
|
|
52
52
|
# Current version of the Diagnosticism library
|
53
|
-
VERSION = '0.
|
53
|
+
VERSION = '0.1.0'
|
54
54
|
|
55
55
|
private
|
56
56
|
VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
|
@@ -63,5 +63,6 @@ module Diagnosticism
|
|
63
63
|
VERSION_REVISION = VERSION_PARTS_[2] # :nodoc:
|
64
64
|
end # module Diagnosticism
|
65
65
|
|
66
|
+
|
66
67
|
# ############################## end of file ############################# #
|
67
68
|
|
@@ -0,0 +1,377 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
|
4
|
+
|
5
|
+
require 'diagnosticism/doomgram'
|
6
|
+
|
7
|
+
require 'xqsr3/extensions/test/unit'
|
8
|
+
require 'test/unit'
|
9
|
+
|
10
|
+
|
11
|
+
class Test_DoomGram < Test::Unit::TestCase
|
12
|
+
|
13
|
+
include ::Diagnosticism
|
14
|
+
|
15
|
+
def test_empty
|
16
|
+
|
17
|
+
dg = DOOMGram.new
|
18
|
+
|
19
|
+
dg.freeze
|
20
|
+
|
21
|
+
assert_equal 0, dg.event_count
|
22
|
+
|
23
|
+
assert_equal 0, dg.total_event_time_ns
|
24
|
+
assert_nil dg.min_event_time_ns
|
25
|
+
assert_nil dg.max_event_time_ns
|
26
|
+
|
27
|
+
assert_equal 0, dg.num_events_in_1ns
|
28
|
+
assert_equal 0, dg.num_events_in_10ns
|
29
|
+
assert_equal 0, dg.num_events_in_100ns
|
30
|
+
assert_equal 0, dg.num_events_in_1us
|
31
|
+
assert_equal 0, dg.num_events_in_10us
|
32
|
+
assert_equal 0, dg.num_events_in_100us
|
33
|
+
assert_equal 0, dg.num_events_in_1ms
|
34
|
+
assert_equal 0, dg.num_events_in_10ms
|
35
|
+
assert_equal 0, dg.num_events_in_100ms
|
36
|
+
assert_equal 0, dg.num_events_in_1s
|
37
|
+
assert_equal 0, dg.num_events_in_10s
|
38
|
+
assert_equal 0, dg.num_events_ge_100s
|
39
|
+
|
40
|
+
assert_equal "____________", dg.to_s
|
41
|
+
assert_equal "____________", dg.to_strip
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_single_timing_event
|
45
|
+
|
46
|
+
dg = DOOMGram.new
|
47
|
+
|
48
|
+
dg.push_event_time_ms 13
|
49
|
+
|
50
|
+
assert_equal 1, dg.event_count
|
51
|
+
|
52
|
+
assert_equal 13000000, dg.total_event_time_ns
|
53
|
+
assert_equal 13000000, dg.min_event_time_ns
|
54
|
+
assert_equal 13000000, dg.max_event_time_ns
|
55
|
+
|
56
|
+
assert_equal 0, dg.num_events_in_1ns
|
57
|
+
assert_equal 0, dg.num_events_in_10ns
|
58
|
+
assert_equal 0, dg.num_events_in_100ns
|
59
|
+
assert_equal 0, dg.num_events_in_1us
|
60
|
+
assert_equal 0, dg.num_events_in_10us
|
61
|
+
assert_equal 0, dg.num_events_in_100us
|
62
|
+
assert_equal 0, dg.num_events_in_1ms
|
63
|
+
assert_equal 1, dg.num_events_in_10ms
|
64
|
+
assert_equal 0, dg.num_events_in_100ms
|
65
|
+
assert_equal 0, dg.num_events_in_1s
|
66
|
+
assert_equal 0, dg.num_events_in_10s
|
67
|
+
assert_equal 0, dg.num_events_ge_100s
|
68
|
+
|
69
|
+
assert_equal "_______a____", dg.to_s
|
70
|
+
assert_equal "_______a____", dg.to_strip
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_zero_time_events
|
74
|
+
|
75
|
+
dg = DOOMGram.new
|
76
|
+
|
77
|
+
dg.push_event_time_ns 0
|
78
|
+
dg.push_event_time_us 0
|
79
|
+
dg.push_event_time_ms 0
|
80
|
+
dg.push_event_time_s 0
|
81
|
+
|
82
|
+
assert_equal 4, dg.event_count
|
83
|
+
|
84
|
+
assert_equal 0, dg.total_event_time_ns
|
85
|
+
assert_equal 0, dg.min_event_time_ns
|
86
|
+
assert_equal 0, dg.max_event_time_ns
|
87
|
+
|
88
|
+
assert_equal 0, dg.num_events_in_1ns
|
89
|
+
assert_equal 0, dg.num_events_in_10ns
|
90
|
+
assert_equal 0, dg.num_events_in_100ns
|
91
|
+
assert_equal 0, dg.num_events_in_1us
|
92
|
+
assert_equal 0, dg.num_events_in_10us
|
93
|
+
assert_equal 0, dg.num_events_in_100us
|
94
|
+
assert_equal 0, dg.num_events_in_1ms
|
95
|
+
assert_equal 0, dg.num_events_in_10ms
|
96
|
+
assert_equal 0, dg.num_events_in_100ms
|
97
|
+
assert_equal 0, dg.num_events_in_1s
|
98
|
+
assert_equal 0, dg.num_events_in_10s
|
99
|
+
assert_equal 0, dg.num_events_ge_100s
|
100
|
+
|
101
|
+
assert_equal "____________", dg.to_s
|
102
|
+
assert_equal "____________", dg.to_strip
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_uniform_spread_timings_1
|
106
|
+
|
107
|
+
dg = DOOMGram.new
|
108
|
+
|
109
|
+
dg.push_event_time_ns 9
|
110
|
+
dg.push_event_time_ns 80
|
111
|
+
dg.push_event_time_ns 700
|
112
|
+
dg.push_event_time_us 6
|
113
|
+
dg.push_event_time_us 50
|
114
|
+
dg.push_event_time_us 400
|
115
|
+
dg.push_event_time_ms 3
|
116
|
+
dg.push_event_time_ms 20
|
117
|
+
dg.push_event_time_ms 100
|
118
|
+
dg.push_event_time_s 9
|
119
|
+
dg.push_event_time_s 80
|
120
|
+
dg.push_event_time_s 700
|
121
|
+
|
122
|
+
|
123
|
+
assert_equal 12, dg.event_count
|
124
|
+
|
125
|
+
assert_equal 789123456789, dg.total_event_time_ns
|
126
|
+
assert_equal 9, dg.min_event_time_ns
|
127
|
+
assert_equal 700_000_000_000, dg.max_event_time_ns
|
128
|
+
|
129
|
+
assert_equal 1, dg.num_events_in_1ns
|
130
|
+
assert_equal 1, dg.num_events_in_10ns
|
131
|
+
assert_equal 1, dg.num_events_in_100ns
|
132
|
+
assert_equal 1, dg.num_events_in_1us
|
133
|
+
assert_equal 1, dg.num_events_in_10us
|
134
|
+
assert_equal 1, dg.num_events_in_100us
|
135
|
+
assert_equal 1, dg.num_events_in_1ms
|
136
|
+
assert_equal 1, dg.num_events_in_10ms
|
137
|
+
assert_equal 1, dg.num_events_in_100ms
|
138
|
+
assert_equal 1, dg.num_events_in_1s
|
139
|
+
assert_equal 1, dg.num_events_in_10s
|
140
|
+
assert_equal 1, dg.num_events_ge_100s
|
141
|
+
|
142
|
+
assert_equal "aaaaaaaaaaaa", dg.to_s
|
143
|
+
assert_equal "aaaaaaaaaaaa", dg.to_strip
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_uniform_spread_timings_2
|
147
|
+
|
148
|
+
dg = DOOMGram.new
|
149
|
+
|
150
|
+
dg.push_event_time_ns 9
|
151
|
+
dg.push_event_time_ns 80
|
152
|
+
dg.push_event_time_ns 700
|
153
|
+
dg.push_event_time_ns 6000
|
154
|
+
dg.push_event_time_ns 50000
|
155
|
+
dg.push_event_time_ns 400000
|
156
|
+
dg.push_event_time_ms 3
|
157
|
+
dg.push_event_time_ms 20
|
158
|
+
dg.push_event_time_ms 100
|
159
|
+
dg.push_event_time_ms 9000
|
160
|
+
dg.push_event_time_ms 80000
|
161
|
+
dg.push_event_time_ms 700000
|
162
|
+
|
163
|
+
assert_equal 12, dg.event_count
|
164
|
+
|
165
|
+
assert_equal 789123456789, dg.total_event_time_ns
|
166
|
+
assert_equal 9, dg.min_event_time_ns
|
167
|
+
assert_equal 700_000_000_000, dg.max_event_time_ns
|
168
|
+
|
169
|
+
assert_equal 1, dg.num_events_in_1ns
|
170
|
+
assert_equal 1, dg.num_events_in_10ns
|
171
|
+
assert_equal 1, dg.num_events_in_100ns
|
172
|
+
assert_equal 1, dg.num_events_in_1us
|
173
|
+
assert_equal 1, dg.num_events_in_10us
|
174
|
+
assert_equal 1, dg.num_events_in_100us
|
175
|
+
assert_equal 1, dg.num_events_in_1ms
|
176
|
+
assert_equal 1, dg.num_events_in_10ms
|
177
|
+
assert_equal 1, dg.num_events_in_100ms
|
178
|
+
assert_equal 1, dg.num_events_in_1s
|
179
|
+
assert_equal 1, dg.num_events_in_10s
|
180
|
+
assert_equal 1, dg.num_events_ge_100s
|
181
|
+
|
182
|
+
assert_equal "aaaaaaaaaaaa", dg.to_s
|
183
|
+
assert_equal "aaaaaaaaaaaa", dg.to_strip
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_uniform_spread_timings_3
|
187
|
+
|
188
|
+
dg = DOOMGram.new
|
189
|
+
|
190
|
+
dg.push_event_time_ns 9
|
191
|
+
dg.push_event_time_ns 80
|
192
|
+
dg.push_event_time_ns 700
|
193
|
+
dg.push_event_time_ns 6000
|
194
|
+
dg.push_event_time_ns 50000
|
195
|
+
dg.push_event_time_ns 400000
|
196
|
+
dg.push_event_time_ns 3000000
|
197
|
+
dg.push_event_time_ns 20000000
|
198
|
+
dg.push_event_time_ns 100000000
|
199
|
+
dg.push_event_time_ns 9000000000
|
200
|
+
dg.push_event_time_ns 80000000000
|
201
|
+
dg.push_event_time_ns 700000000000
|
202
|
+
|
203
|
+
assert_equal 12, dg.event_count
|
204
|
+
|
205
|
+
assert_equal 789123456789, dg.total_event_time_ns
|
206
|
+
assert_equal 9, dg.min_event_time_ns
|
207
|
+
assert_equal 700_000_000_000, dg.max_event_time_ns
|
208
|
+
|
209
|
+
assert_equal 1, dg.num_events_in_1ns
|
210
|
+
assert_equal 1, dg.num_events_in_10ns
|
211
|
+
assert_equal 1, dg.num_events_in_100ns
|
212
|
+
assert_equal 1, dg.num_events_in_1us
|
213
|
+
assert_equal 1, dg.num_events_in_10us
|
214
|
+
assert_equal 1, dg.num_events_in_100us
|
215
|
+
assert_equal 1, dg.num_events_in_1ms
|
216
|
+
assert_equal 1, dg.num_events_in_10ms
|
217
|
+
assert_equal 1, dg.num_events_in_100ms
|
218
|
+
assert_equal 1, dg.num_events_in_1s
|
219
|
+
assert_equal 1, dg.num_events_in_10s
|
220
|
+
assert_equal 1, dg.num_events_ge_100s
|
221
|
+
|
222
|
+
assert_equal "aaaaaaaaaaaa", dg.to_s
|
223
|
+
assert_equal "aaaaaaaaaaaa", dg.to_strip
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_uniform_spread_timings_4
|
227
|
+
|
228
|
+
dg = DOOMGram.new
|
229
|
+
|
230
|
+
dg.push_event_time_us 6
|
231
|
+
dg.push_event_time_us 50
|
232
|
+
dg.push_event_time_us 400
|
233
|
+
dg.push_event_time_us 3000
|
234
|
+
dg.push_event_time_us 20000
|
235
|
+
dg.push_event_time_us 100000
|
236
|
+
dg.push_event_time_us 9000000
|
237
|
+
dg.push_event_time_us 80000000
|
238
|
+
dg.push_event_time_us 700000000
|
239
|
+
|
240
|
+
assert_equal 9, dg.event_count
|
241
|
+
|
242
|
+
assert_equal 789123456000, dg.total_event_time_ns
|
243
|
+
assert_equal 6_000, dg.min_event_time_ns
|
244
|
+
assert_equal 700_000_000_000, dg.max_event_time_ns
|
245
|
+
|
246
|
+
assert_equal 0, dg.num_events_in_1ns
|
247
|
+
assert_equal 0, dg.num_events_in_10ns
|
248
|
+
assert_equal 0, dg.num_events_in_100ns
|
249
|
+
assert_equal 1, dg.num_events_in_1us
|
250
|
+
assert_equal 1, dg.num_events_in_10us
|
251
|
+
assert_equal 1, dg.num_events_in_100us
|
252
|
+
assert_equal 1, dg.num_events_in_1ms
|
253
|
+
assert_equal 1, dg.num_events_in_10ms
|
254
|
+
assert_equal 1, dg.num_events_in_100ms
|
255
|
+
assert_equal 1, dg.num_events_in_1s
|
256
|
+
assert_equal 1, dg.num_events_in_10s
|
257
|
+
assert_equal 1, dg.num_events_ge_100s
|
258
|
+
|
259
|
+
assert_equal "___aaaaaaaaa", dg.to_s
|
260
|
+
assert_equal "___aaaaaaaaa", dg.to_strip
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_several_distinct_timings
|
264
|
+
|
265
|
+
dg = DOOMGram.new
|
266
|
+
|
267
|
+
dg.push_event_time_ns 23
|
268
|
+
dg.push_event_time_ns 10
|
269
|
+
dg.push_event_time_us 7
|
270
|
+
dg.push_event_time_us 7
|
271
|
+
dg.push_event_time_us 89
|
272
|
+
dg.push_event_time_ms 248
|
273
|
+
dg.push_event_time_s 5
|
274
|
+
dg.push_event_time_s 309
|
275
|
+
|
276
|
+
assert_equal 8, dg.event_count
|
277
|
+
|
278
|
+
assert_equal 314248103033, dg.total_event_time_ns
|
279
|
+
assert_equal 10, dg.min_event_time_ns
|
280
|
+
assert_equal 309_000_000_000, dg.max_event_time_ns
|
281
|
+
|
282
|
+
assert_equal 0, dg.num_events_in_1ns
|
283
|
+
assert_equal 2, dg.num_events_in_10ns
|
284
|
+
assert_equal 0, dg.num_events_in_100ns
|
285
|
+
assert_equal 2, dg.num_events_in_1us
|
286
|
+
assert_equal 1, dg.num_events_in_10us
|
287
|
+
assert_equal 0, dg.num_events_in_100us
|
288
|
+
assert_equal 0, dg.num_events_in_1ms
|
289
|
+
assert_equal 0, dg.num_events_in_10ms
|
290
|
+
assert_equal 1, dg.num_events_in_100ms
|
291
|
+
assert_equal 1, dg.num_events_in_1s
|
292
|
+
assert_equal 0, dg.num_events_in_10s
|
293
|
+
assert_equal 1, dg.num_events_ge_100s
|
294
|
+
|
295
|
+
assert_equal "_a_aa___aa_a", dg.to_s
|
296
|
+
assert_equal "_a_aa___aa_a", dg.to_strip
|
297
|
+
end
|
298
|
+
|
299
|
+
def test_several_intersecting_timings
|
300
|
+
|
301
|
+
dg = DOOMGram.new
|
302
|
+
|
303
|
+
dg.push_event_time_ns 11
|
304
|
+
dg.push_event_time_ns 19
|
305
|
+
dg.push_event_time_ns 19
|
306
|
+
dg.push_event_time_us 7
|
307
|
+
dg.push_event_time_us 7
|
308
|
+
dg.push_event_time_us 89
|
309
|
+
dg.push_event_time_ms 248
|
310
|
+
dg.push_event_time_ms 4_321
|
311
|
+
dg.push_event_time_s 5
|
312
|
+
dg.push_event_time_s 309
|
313
|
+
|
314
|
+
assert_equal 10, dg.event_count
|
315
|
+
|
316
|
+
assert_equal 318569103049, dg.total_event_time_ns
|
317
|
+
assert_equal 11, dg.min_event_time_ns
|
318
|
+
assert_equal 309_000_000_000, dg.max_event_time_ns
|
319
|
+
|
320
|
+
assert_equal 0, dg.num_events_in_1ns
|
321
|
+
assert_equal 3, dg.num_events_in_10ns
|
322
|
+
assert_equal 0, dg.num_events_in_100ns
|
323
|
+
assert_equal 2, dg.num_events_in_1us
|
324
|
+
assert_equal 1, dg.num_events_in_10us
|
325
|
+
assert_equal 0, dg.num_events_in_100us
|
326
|
+
assert_equal 0, dg.num_events_in_1ms
|
327
|
+
assert_equal 0, dg.num_events_in_10ms
|
328
|
+
assert_equal 1, dg.num_events_in_100ms
|
329
|
+
assert_equal 2, dg.num_events_in_1s
|
330
|
+
assert_equal 0, dg.num_events_in_10s
|
331
|
+
assert_equal 1, dg.num_events_ge_100s
|
332
|
+
|
333
|
+
assert_equal "_a_aa___aa_a", dg.to_s
|
334
|
+
assert_equal "_a_aa___aa_a", dg.to_strip
|
335
|
+
end
|
336
|
+
|
337
|
+
def test_many_cumulative_timings
|
338
|
+
|
339
|
+
dg = DOOMGram.new
|
340
|
+
|
341
|
+
(0...10000).each { dg.push_event_time_ns 1 }
|
342
|
+
|
343
|
+
(0...1000).each { dg.push_event_time_us 1 }
|
344
|
+
|
345
|
+
(0...100).each { dg.push_event_time_ms 1 }
|
346
|
+
|
347
|
+
(0...10).each { dg.push_event_time_s 1 }
|
348
|
+
|
349
|
+
assert_equal 11110, dg.event_count
|
350
|
+
|
351
|
+
assert_equal 10101010000, dg.total_event_time_ns
|
352
|
+
assert_equal 1, dg.min_event_time_ns
|
353
|
+
assert_equal 1_000_000_000, dg.max_event_time_ns
|
354
|
+
|
355
|
+
assert_equal 10_000, dg.num_events_in_1ns
|
356
|
+
assert_equal 0, dg.num_events_in_10ns
|
357
|
+
assert_equal 0, dg.num_events_in_100ns
|
358
|
+
assert_equal 1_000, dg.num_events_in_1us
|
359
|
+
assert_equal 0, dg.num_events_in_10us
|
360
|
+
assert_equal 0, dg.num_events_in_100us
|
361
|
+
assert_equal 100, dg.num_events_in_1ms
|
362
|
+
assert_equal 0, dg.num_events_in_10ms
|
363
|
+
assert_equal 0, dg.num_events_in_100ms
|
364
|
+
assert_equal 10, dg.num_events_in_1s
|
365
|
+
assert_equal 0, dg.num_events_in_10s
|
366
|
+
assert_equal 0, dg.num_events_ge_100s
|
367
|
+
|
368
|
+
assert_equal "e__d__c__b__", dg.to_s
|
369
|
+
assert_equal "e__d__c__b__", dg.to_strip
|
370
|
+
assert_equal "*--d--c--b--", dg.to_strip(range: 'abcd', zero_character: '-')
|
371
|
+
assert_equal "# # c b ", dg.to_strip(range: 'abc', zero_character: ' ', overflow_character: '#')
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
|
376
|
+
# ############################## end of file ############################# #
|
377
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diagnosticism
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Diagnostic facilities, for Ruby
|
14
14
|
|
@@ -20,7 +20,9 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- LICENSE
|
22
22
|
- README.md
|
23
|
+
- lib/diagnosticism/doomgram.rb
|
23
24
|
- lib/diagnosticism/version.rb
|
25
|
+
- test/unit/tc_doomgram.rb
|
24
26
|
- test/unit/ts_all.rb
|
25
27
|
homepage: http://github.com/synesissoftware/Diagnosticism.Ruby
|
26
28
|
licenses:
|