Class: Nanoc::CLI::Commands::Compile::StackProfProfiler 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 a profile using StackProf

Constant Summary collapse

PROFILE_FILE =

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

'tmp/stackprof_profile'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Listener

#initialize, #start_safely, #stop_safely

Constructor Details

This class inherits a constructor from Nanoc::CLI::Commands::Compile::Listener

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:



375
376
377
# File 'lib/nanoc/cli/commands/compile.rb', line 375

def self.enable_for?(command_runner)
  command_runner.options.fetch(:profile, 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:



380
381
382
383
# File 'lib/nanoc/cli/commands/compile.rb', line 380

def start
  require 'stackprof'
  StackProf.start(mode: :cpu)
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:



386
387
388
389
# File 'lib/nanoc/cli/commands/compile.rb', line 386

def stop
  StackProf.stop
  StackProf.results(PROFILE_FILE)
end