Class: Nanoc::CLI::Commands::Compile::TimingRecorder

Inherits:
Listener
  • Object
show all
Defined in:
lib/nanoc/cli/commands/compile.rb

Overview

Records the time spent per filter and per item representation

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reps:) ⇒ TimingRecorder

Returns a new instance of TimingRecorder

Parameters:

  • reps (Enumerable<Nanoc::Int::ItemRep>)


149
150
151
152
153
# File 'lib/nanoc/cli/commands/compile.rb', line 149

def initialize(reps:)
  @times = {}

  @reps = reps
end

Class Method Details

.enable_for?(command_runner) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • Listener#enable_for?


144
145
146
# File 'lib/nanoc/cli/commands/compile.rb', line 144

def self.enable_for?(command_runner)
  command_runner.options.fetch(:verbose, false)
end

Instance Method Details

#startObject

See Also:



156
157
158
159
160
161
162
163
164
# File 'lib/nanoc/cli/commands/compile.rb', line 156

def start
  Nanoc::Int::NotificationCenter.on(:filtering_started) do |_rep, filter_name|
    @times[filter_name] ||= []
    @times[filter_name] << { start: Time.now }
  end
  Nanoc::Int::NotificationCenter.on(:filtering_ended) do |_rep, filter_name|
    @times[filter_name].last[:stop] = Time.now
  end
end

#stopObject

See Also:



167
168
169
170
# File 'lib/nanoc/cli/commands/compile.rb', line 167

def stop
  print_profiling_feedback
  super
end