Sha256: b4fdef63a288ff3308a487011a9b845df29beeba52ff2c26e5e52dcc413d27ed

Contents?: true

Size: 872 Bytes

Versions: 23

Compression:

Stored size: 872 Bytes

Contents

require 'benchmark'
require 'puppet-debugger/input_responder_plugin'
module PuppetDebugger
  module InputResponders
    class Benchmark < InputResponderPlugin
      COMMAND_WORDS = %w(benchmark bm)
      SUMMARY = 'Benchmark your Puppet code.'
      COMMAND_GROUP = :tools

      def run(args = [])
        if args.count > 0
          enable(false)
          out = debugger.handle_input(args.first)
          disable
          out
        else
          status = debugger.bench ? disable : enable(true)
          "Benchmark Mode #{status}"
        end
      end

      private

      def disable
        debugger.bench = false
        debugger.extra_prompt = ''
        'Off'
      end

      def enable(show_status = false)
        debugger.bench = true
        if show_status
          debugger.extra_prompt = 'BM'
          'On'
        end
      end

    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
puppet-debugger-0.19.0 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.18.0 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.17.0 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.16.0 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.15.2 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.15.1 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.15.0 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.14.0 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.13.0 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.12.3 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.12.2 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.12.1 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.12.0 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.11.0 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.10.3 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.10.2 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.10.1 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.10.0 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.9.1 lib/plugins/puppet-debugger/input_responders/benchmark.rb
puppet-debugger-0.9.0 lib/plugins/puppet-debugger/input_responders/benchmark.rb