From fda26e84ccffed1c41e546930a7856171dc38e02 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 18 Dec 2024 00:34:36 -0500 Subject: [PATCH] try to make snapshot benchmark validate faster --- benchmarks/di_snapshot.rb | 11 ++++++++++- spec/datadog/di/validate_benchmarks_spec.rb | 10 +++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/benchmarks/di_snapshot.rb b/benchmarks/di_snapshot.rb index a27fa44e92e..09ffc4d9e93 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 9c28bb3e5be..3df628e8243 100644 --- a/spec/datadog/di/validate_benchmarks_spec.rb +++ b/spec/datadog/di/validate_benchmarks_spec.rb @@ -20,15 +20,19 @@ else 10 end - it("runs without raising errors") do - expect_in_fork(timeout_seconds: timeout) { load "./benchmarks/#{benchmark}.rb" } + it "runs without raising errors" do + expect_in_fork(timeout_seconds: timeout) do + load "./benchmarks/#{benchmark}.rb" + end 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