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

- (TimingRecorder) initialize(params = {})

Returns a new instance of TimingRecorder

Parameters:

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):



164
165
166
167
168
# File 'lib/nanoc/cli/commands/compile.rb', line 164

def initialize(params = {})
  @times = {}

  @reps = params.fetch(:reps)
end

Class Method Details

+ (Boolean) enable_for?(command_runner)

Returns:

  • (Boolean)

See Also:

  • Listener#enable_for?


159
160
161
# File 'lib/nanoc/cli/commands/compile.rb', line 159

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

Instance Method Details

- (Object) start

See Also:



171
172
173
174
175
176
177
178
179
# File 'lib/nanoc/cli/commands/compile.rb', line 171

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

- (Object) stop

See Also:



182
183
184
185
# File 'lib/nanoc/cli/commands/compile.rb', line 182

def stop
  print_profiling_feedback
  super
end