diff options
| author | Paul Buetow <paul@buetow.org> | 2026-07-22 23:52:43 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-07-22 23:52:43 +0300 |
| commit | 17bf7e042496a4afcbf6ee7a583378adb3ec502d (patch) | |
| tree | 380d89c2ca5157a067244857aa4fd5ebf2387915 /benchmarks/benchmark_test.go | |
| parent | bc2767c87c4090798c4c7d15e101ed066e947301 (diff) | |
build: DTail fork — benchmarks, PGO tooling, Makefile, docker
Squashed development of the build/benchmark/profiling tooling:
- Turbo-vs-normal and per-tool benchmark harnesses under benchmarks/ (with dated
baseline and result artifacts preserved), plus MapReduce/SSH/network suites.
- Profile-Guided Optimization workflow (internal/tools/pgo lives with the code):
Makefile targets (make pgo / pgo-quick / build-pgo), profile generation with
non-zero-sample and representativeness guards.
- Makefile targets for build, test (unit + integration), lint, vet, benchmarking
and profiling; docker config updates.
- .gitignore hardened against pgo profiles and accidental integration-test
debug/output dumps.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'benchmarks/benchmark_test.go')
| -rw-r--r-- | benchmarks/benchmark_test.go | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/benchmarks/benchmark_test.go b/benchmarks/benchmark_test.go new file mode 100644 index 0000000..baa53fc --- /dev/null +++ b/benchmarks/benchmark_test.go @@ -0,0 +1,69 @@ +package benchmarks + +import ( + "fmt" + "os" + "testing" +) + +// TestMain sets up and tears down the benchmark environment +func TestMain(m *testing.M) { + // Clean up any leftover files before starting + if err := CleanupBenchmarkFiles(""); err != nil { + fmt.Fprintf(os.Stderr, "Warning: failed to cleanup old files: %v\n", err) + } + + // Run tests/benchmarks + code := m.Run() + + // Clean up after benchmarks unless asked to keep files + if os.Getenv("DTAIL_BENCH_KEEP_FILES") != "true" { + if err := CleanupBenchmarkFiles(""); err != nil { + fmt.Fprintf(os.Stderr, "Warning: failed to cleanup files: %v\n", err) + } + } + + os.Exit(code) +} + +// BenchmarkAll runs a representative subset of all benchmarks +func BenchmarkAll(b *testing.B) { + b.Run("DCat", func(b *testing.B) { + BenchmarkDCatSimple(b) + }) + + b.Run("DGrep", func(b *testing.B) { + BenchmarkDGrepSimplePattern(b) + }) + + b.Run("DMap", func(b *testing.B) { + BenchmarkDMapSimpleAggregation(b) + }) +} + +// BenchmarkQuick runs only quick benchmarks with small files +func BenchmarkQuick(b *testing.B) { + // Set quick mode + oldQuick := os.Getenv("DTAIL_BENCH_QUICK") + os.Setenv("DTAIL_BENCH_QUICK", "true") + defer func() { + if oldQuick == "" { + os.Unsetenv("DTAIL_BENCH_QUICK") + } else { + os.Setenv("DTAIL_BENCH_QUICK", oldQuick) + } + }() + + // Set small files only + oldSizes := os.Getenv("DTAIL_BENCH_SIZES") + os.Setenv("DTAIL_BENCH_SIZES", "small") + defer func() { + if oldSizes == "" { + os.Unsetenv("DTAIL_BENCH_SIZES") + } else { + os.Setenv("DTAIL_BENCH_SIZES", oldSizes) + } + }() + + BenchmarkAll(b) +}
\ No newline at end of file |
