Class: Nanoc::CLI::Commands::Compile::StackProfProfiler

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

Overview

Records a profile using StackProf

Constant Summary

PROFILE_FILE =
'tmp/stackprof_profile'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Listener

#initialize

Constructor Details

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

Class Method Details

.enable_for?(command_runner) ⇒ Boolean

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

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

See Also:



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

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