Class/Module Index [+]

Quicksearch

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

Records the time spent per filter and per item representation

Public Class Methods

enable_for?(command_runner) click to toggle source

@see Listener#enable_for?

# File lib/nanoc/cli/commands/compile.rb, line 158
def self.enable_for?(command_runner)
  command_runner.options.fetch(:verbose, false)
end
new(params = {}) click to toggle source

@option params [Array<Nanoc::ItemRep>] :reps The list of item representations in the site

# File lib/nanoc/cli/commands/compile.rb, line 163
def initialize(params = {})
  @times = {}

  @reps = params.fetch(:reps)
end

Public Instance Methods

start() click to toggle source

@see Listener#start

# File lib/nanoc/cli/commands/compile.rb, line 170
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
stop() click to toggle source

@see Listener#stop

# File lib/nanoc/cli/commands/compile.rb, line 181
def stop
  print_profiling_feedback
  super
end

Protected Instance Methods

durations_for_filter(filter_name) click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 246
def durations_for_filter(filter_name)
  result = []
  @times[filter_name].each do |sample|
    if sample[:start] && sample[:stop]
      result << sample[:stop] - sample[:start]
    end
  end
  result
end
durations_per_filter() click to toggle source
# File lib/nanoc/cli/commands/compile.rb, line 233
def durations_per_filter
  @_durations_per_filter ||= begin
    result = {}
    @times.keys.each do |filter_name|
      durations = durations_for_filter(filter_name)
      if durations
        result[filter_name] = durations
      end
    end
    result
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.