Class: Wavesync::Timing

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeTiming

: () -> 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

.currentObject

: () -> Timing



9
10
11
# File 'lib/wavesync/timing.rb', line 9

def self.current
  @current ||= new
end

.resetObject

: () -> 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

#totalsObject

: () -> Hash[Symbol, Float]



32
33
34
# File 'lib/wavesync/timing.rb', line 32

def totals
  @totals.dup
end