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

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Records the time spent per filter and per item representation

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Listener

#start_safely, #stop_safely

Constructor Details

#initialize(reps:) ⇒ TimingRecorder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TimingRecorder.

Parameters:



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

def initialize(reps:)
  @times = {}

  @reps = reps
end

Class Method Details

.enable_for?(command_runner) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

See Also:



161
162
163
# File 'lib/nanoc/cli/commands/compile.rb', line 161

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

Instance Method Details

#startObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

See Also:



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

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

See Also:



184
185
186
187
# File 'lib/nanoc/cli/commands/compile.rb', line 184

def stop
  print_profiling_feedback
  super
end