Skip to content

Commit

Permalink
DEBUG-2657 prefix benchmark names with the product as per their sourc…
Browse files Browse the repository at this point in the history
…e file (#3828)
  • Loading branch information
p-datadog committed Aug 12, 2024
1 parent 46c8c8b commit 92b624d
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 24 deletions.
3 changes: 3 additions & 0 deletions benchmarks/benchmarks_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require 'datadog'
require 'pry'
require_relative 'benchmarks_ips_patch'
26 changes: 26 additions & 0 deletions benchmarks/benchmarks_ips_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'benchmark/ips'

module JobReporter
def report(name, *args, **opts, &block)
caller_path = caller_locations.first.path
prefix = File.basename(caller_path).sub(/_.*\z/, '')
name = "#{prefix} - #{name}"
# Older Rubies (e.g. 2.5) do not permit passing *args and &block
# in the same invocation.
if args.any? && block_given?
raise ArgumentError, 'Unsupported usage'
elsif block_given?
if opts.any?
super(name, **opts, &block)
else
super(name, &block)
end
else
super(name, *args, **opts)
end
end
end

class Benchmark::IPS::Job
prepend JobReporter
end
7 changes: 6 additions & 1 deletion benchmarks/library_gem_loading.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

return unless __FILE__ == $PROGRAM_NAME || VALIDATE_BENCHMARK_MODE

require_relative 'benchmarks_helper'
require 'open3'

class GemLoadingBenchmark
Expand All @@ -18,6 +19,7 @@ def benchmark_gem_loading
lib = File.expand_path('../lib', '#{__dir__}')
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
$LOAD_PATH.unshift('#{__dir__}')
VALIDATE_BENCHMARK_MODE = #{VALIDATE_BENCHMARK_MODE}
require 'benchmark/ips'
Expand All @@ -27,7 +29,10 @@ def benchmark_gem_loading
benchmark_time = VALIDATE_BENCHMARK_MODE ? { time: 0.001, warmup: 0 } : { time: 60, warmup: 5 }
x.config(**benchmark_time)
x.report("Gem loading") do
# Because this benchmark is run in a forked process that is passed
# the code via standard input, it cannot figure out the product
# prefix automatically.
x.report("library - Gem loading") do
pid = fork { require 'datadog' }
_, status = Process.wait2(pid)
Expand Down
4 changes: 1 addition & 3 deletions benchmarks/profiler_allocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

return unless __FILE__ == $PROGRAM_NAME || VALIDATE_BENCHMARK_MODE

require 'benchmark/ips'
require 'datadog'
require 'pry'
require_relative 'benchmarks_helper'

# This benchmark measures the performance of allocation profiling

Expand Down
4 changes: 1 addition & 3 deletions benchmarks/profiler_gc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

return unless __FILE__ == $PROGRAM_NAME || VALIDATE_BENCHMARK_MODE

require 'benchmark/ips'
require 'datadog'
require 'pry'
require_relative 'benchmarks_helper'

# This benchmark measures the performance of GC profiling

Expand Down
4 changes: 1 addition & 3 deletions benchmarks/profiler_hold_resume_interruptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

return unless __FILE__ == $PROGRAM_NAME || VALIDATE_BENCHMARK_MODE

require 'benchmark/ips'
require 'datadog'
require 'pry'
require_relative 'benchmarks_helper'

# This benchmark measures the performance of the hold/resume interruptions used by the DirMonkeyPatches
class ProfilerHoldResumeInterruptions
Expand Down
4 changes: 1 addition & 3 deletions benchmarks/profiler_http_transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

return unless __FILE__ == $PROGRAM_NAME || VALIDATE_BENCHMARK_MODE

require 'benchmark/ips'
require 'datadog'
require 'pry'
require_relative 'benchmarks_helper'
require 'securerandom'
require 'socket'

Expand Down
4 changes: 1 addition & 3 deletions benchmarks/profiler_memory_sample_serialize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

return unless __FILE__ == $PROGRAM_NAME || VALIDATE_BENCHMARK_MODE

require 'benchmark/ips'
require 'datadog'
require 'pry'
require_relative 'benchmarks_helper'

require 'libdatadog'

Expand Down
4 changes: 1 addition & 3 deletions benchmarks/profiler_sample_loop_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

return unless __FILE__ == $PROGRAM_NAME || VALIDATE_BENCHMARK_MODE

require 'benchmark/ips'
require 'datadog'
require 'pry'
require_relative 'benchmarks_helper'

# This benchmark measures the performance of the main stack sampling loop of the profiler

Expand Down
4 changes: 1 addition & 3 deletions benchmarks/profiler_sample_serialize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

return unless __FILE__ == $PROGRAM_NAME || VALIDATE_BENCHMARK_MODE

require 'benchmark/ips'
require 'datadog'
require 'pry'
require_relative 'benchmarks_helper'

require 'libdatadog'

Expand Down
3 changes: 1 addition & 2 deletions benchmarks/tracing_trace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

return unless __FILE__ == $PROGRAM_NAME || VALIDATE_BENCHMARK_MODE

require 'benchmark/ips'
require 'datadog'
require_relative 'benchmarks_helper'

class TracingTraceBenchmark
module NoopWriter
Expand Down

0 comments on commit 92b624d

Please sign in to comment.