Class: Wavesync::Timing
- Inherits:
-
Object
- Object
- Wavesync::Timing
- Defined in:
- lib/wavesync/timing.rb
Constant Summary collapse
- BUCKETS =
%i[transcode probe ffmpeg_metadata copy wav_chunks mp4_chunks filesystem].freeze
Class Method Summary collapse
-
.current ⇒ Object
: () -> Timing.
-
.reset ⇒ Object
: () -> void.
Instance Method Summary collapse
-
#initialize ⇒ Timing
constructor
: () -> void.
-
#measure(bucket) ⇒ Object
: (Symbol bucket) { () -> untyped } -> untyped.
-
#totals ⇒ Object
: () -> Hash[Symbol, Float].
Constructor Details
#initialize ⇒ Timing
: () -> void
19 20 21 |
# File 'lib/wavesync/timing.rb', line 19 def initialize @totals = Hash.new(0.0) #: Hash[Symbol, Float] end |
Class Method Details
.current ⇒ Object
: () -> Timing
9 10 11 |
# File 'lib/wavesync/timing.rb', line 9 def self.current @current ||= new end |
.reset ⇒ Object
: () -> void
14 15 16 |
# File 'lib/wavesync/timing.rb', line 14 def self.reset @current = new end |
Instance Method Details
#measure(bucket) ⇒ Object
: (Symbol bucket) { () -> untyped } -> untyped
24 25 26 27 28 29 |
# File 'lib/wavesync/timing.rb', line 24 def measure(bucket) start = Process.clock_gettime(Process::CLOCK_MONOTONIC) yield ensure @totals[bucket] += Process.clock_gettime(Process::CLOCK_MONOTONIC) - start end |
#totals ⇒ Object
: () -> Hash[Symbol, Float]
32 33 34 |
# File 'lib/wavesync/timing.rb', line 32 def totals @totals.dup end |