Skip to content

Commit

Permalink
try to make snapshot benchmark validate faster
Browse files Browse the repository at this point in the history
  • Loading branch information
p committed Dec 18, 2024
1 parent c85a791 commit fda26e8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 10 additions & 1 deletion benchmarks/di_snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
10 changes: 7 additions & 3 deletions spec/datadog/di/validate_benchmarks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fda26e8

Please sign in to comment.