diff --git a/benchmarks/di_snapshot.rb b/benchmarks/di_snapshot.rb index a27fa44e92..09ffc4d9e9 100644 --- a/benchmarks/di_snapshot.rb +++ b/benchmarks/di_snapshot.rb @@ -39,7 +39,8 @@ require 'webrick' class DISnapshotBenchmark - BASIC_RATE_LIMIT = 5000 + # If we are validating the benchmark a single operation is sufficient. + BASIC_RATE_LIMIT = VALIDATE_BENCHMARK_MODE ? 1 : 5000 ENRICHED_RATE_LIMIT = 1 def initialize @@ -60,6 +61,14 @@ def initialize end Thread.new do + # If there is an actual Datadog agent running locally, the server + # used in this benchmark will fail to start. + # Using an actual Datadog agent instead of the fake server should not + # affect the indication of whether the rate limit is reachable + # since the agent shouldn't take longer to process than the fake + # web server (and the agent should also run on another core), + # however using a real agent would forego reports of the number of + # snapshots submitted and their size. server.start end diff --git a/spec/datadog/di/validate_benchmarks_spec.rb b/spec/datadog/di/validate_benchmarks_spec.rb index fbe4a00e8f..234728ea45 100644 --- a/spec/datadog/di/validate_benchmarks_spec.rb +++ b/spec/datadog/di/validate_benchmarks_spec.rb @@ -15,13 +15,17 @@ benchmarks_to_validate.each do |benchmark| describe benchmark do - it("runs without raising errors") { expect_in_fork { load "./benchmarks/#{benchmark}.rb" } } + it "runs without raising errors" do + expect_in_fork { load "./benchmarks/#{benchmark}.rb" } + end end end # This test validates that we don't forget to add new benchmarks to benchmarks_to_validate it "tests all expected benchmarks in the benchmarks folder" do - all_benchmarks = Dir["./benchmarks/di_*"].map { |it| it.gsub("./benchmarks/", "").gsub(".rb", "") } + all_benchmarks = Dir["./benchmarks/di_*"].map do |it| + it.gsub("./benchmarks/", "").gsub(".rb", "") + end expect(benchmarks_to_validate).to contain_exactly(*all_benchmarks) end