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 54796a5 commit 55c04e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 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
8 changes: 6 additions & 2 deletions spec/datadog/di/validate_benchmarks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 55c04e4

Please sign in to comment.