Sha256: ecabaddae2fc64756daa17d21f3021194a118a38a7786ac2beb3c9f678370cbd

Contents?: true

Size: 516 Bytes

Versions: 5

Compression:

Stored size: 516 Bytes

Contents

# frozen_string_literal: true

module Nanoc::CLI::Commands::CompileListeners
  class StackProfProfiler < Abstract
    PROFILE_FILE = 'tmp/stackprof_profile'

    # @see Listener#enable_for?
    def self.enable_for?(command_runner)
      command_runner.options.fetch(:profile, false)
    end

    # @see Listener#start
    def start
      require 'stackprof'
      StackProf.start(mode: :cpu)
    end

    # @see Listener#stop
    def stop
      StackProf.stop
      StackProf.results(PROFILE_FILE)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nanoc-4.7.14 lib/nanoc/cli/commands/compile_listeners/stack_prof_profiler.rb
nanoc-4.7.13 lib/nanoc/cli/commands/compile_listeners/stack_prof_profiler.rb
nanoc-4.7.12 lib/nanoc/cli/commands/compile_listeners/stack_prof_profiler.rb
nanoc-4.7.11 lib/nanoc/cli/commands/compile_listeners/stack_prof_profiler.rb
nanoc-4.7.10 lib/nanoc/cli/commands/compile_listeners/stack_prof_profiler.rb