Sha256: 48b5e778648bec1fffeaa220fbc53eaffbe270f1d2f344fd6bf70872751fa5c0

Contents?: true

Size: 909 Bytes

Versions: 30

Compression:

Stored size: 909 Bytes

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

module Performance
  module Instrumentation
    class PerfToolsProfile < Instrumentor
      platforms :mri_19, :mri_20, :mri_21

      def self.setup
        require 'tmpdir'
        require 'perftools'
      end

      def before(test, test_name)
        @profile_dir = Dir.mktmpdir('profile')
        @profile_path = File.join(@profile_dir, "profile")
        PerfTools::CpuProfiler.start(@profile_path)
      end

      def after(test, test_name)
        PerfTools::CpuProfiler.stop
        output_profile_path = artifact_path(test, test_name, "dot")
        system("pprof.rb --dot #{@profile_path} >#{output_profile_path}")
        @artifacts << output_profile_path
        FileUtils.remove_entry_secure(@profile_dir)
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
newrelic_rpm-3.12.1.298 test/performance/lib/performance/instrumentation/perf_tools.rb
newrelic_rpm-3.12.0.288 test/performance/lib/performance/instrumentation/perf_tools.rb
newrelic_rpm-3.11.2.286 test/performance/lib/performance/instrumentation/perf_tools.rb
newrelic_rpm-3.11.1.284 test/performance/lib/performance/instrumentation/perf_tools.rb
newrelic_rpm-3.11.0.283 test/performance/lib/performance/instrumentation/perf_tools.rb
newrelic_rpm-3.10.0.279 test/performance/lib/performance/instrumentation/perf_tools.rb
newrelic_rpm-3.9.9.275 test/performance/lib/performance/instrumentation/perf_tools.rb
newrelic_rpm-3.9.8.273 test/performance/lib/performance/instrumentation/perf_tools.rb
newrelic_rpm-3.9.7.266 test/performance/lib/performance/instrumentation/perf_tools.rb
newrelic_rpm-3.9.6.257 test/performance/lib/performance/instrumentation/perf_tools.rb