Class: AceMQ::AMQP::Telemetry::Registry::Timing
- Inherits:
-
Object
- Object
- AceMQ::AMQP::Telemetry::Registry::Timing
- Defined in:
- lib/acemq/amqp/telemetry.rb
Overview
What a registry knows about a timing.
Deliberately not percentiles. Computing those needs either every sample kept or a sketch, and a library that quietly did either would be making a decision about this process's memory that belongs to whoever runs it.
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
-
#sum ⇒ Object
readonly
Returns the value of attribute sum.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(count, sum, min, max) ⇒ Timing
constructor
A new instance of Timing.
- #mean ⇒ Object
-
#plus(value) ⇒ Object
Adds one sample, giving back a new timing rather than changing this one, so a reader holding a timing is holding a number that was true when it read it.
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(count, sum, min, max) ⇒ Timing
Returns a new instance of Timing.
326 327 328 329 330 331 332 |
# File 'lib/acemq/amqp/telemetry.rb', line 326 def initialize(count, sum, min, max) @count = count @sum = sum @min = min @max = max freeze end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
324 325 326 |
# File 'lib/acemq/amqp/telemetry.rb', line 324 def count @count end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
324 325 326 |
# File 'lib/acemq/amqp/telemetry.rb', line 324 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
324 325 326 |
# File 'lib/acemq/amqp/telemetry.rb', line 324 def min @min end |
#sum ⇒ Object (readonly)
Returns the value of attribute sum.
324 325 326 |
# File 'lib/acemq/amqp/telemetry.rb', line 324 def sum @sum end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
343 |
# File 'lib/acemq/amqp/telemetry.rb', line 343 def ==(other) = other.is_a?(Timing) && to_a == other.to_a |
#hash ⇒ Object
345 |
# File 'lib/acemq/amqp/telemetry.rb', line 345 def hash = to_a.hash |
#mean ⇒ Object
341 |
# File 'lib/acemq/amqp/telemetry.rb', line 341 def mean = @count.zero? ? 0.0 : @sum / @count |
#plus(value) ⇒ Object
Adds one sample, giving back a new timing rather than changing this one, so a reader holding a timing is holding a number that was true when it read it.
337 338 339 |
# File 'lib/acemq/amqp/telemetry.rb', line 337 def plus(value) Timing.new(@count + 1, @sum + value, [@min, value].min, [@max, value].max) end |
#to_a ⇒ Object
342 |
# File 'lib/acemq/amqp/telemetry.rb', line 342 def to_a = [@count, @sum, @min, @max] |
#to_s ⇒ Object
346 |
# File 'lib/acemq/amqp/telemetry.rb', line 346 def to_s = "#{@count} in #{format("%.3f", @sum)}s (mean #{format("%.4f", mean)}s)" |