Skip to content

Commit 41c07dc

Browse files
committed
Allow to run only specific tests
1 parent b3e7eac commit 41c07dc

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/test/db_benchmark/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ To modify test parameters, provide environment variables:
103103
- `KEYS_PER_BLOCK`: Number of keys per block
104104
- `VALUE_SIZE`: Size of each value in bytes
105105
- `WARMUP_BLOCKS`: Number of blocks to warmup with
106+
- `BENCHMARKS`: Comma-separated list of benchmarks to run
106107

107108
## Troubleshooting
108109

src/test/db_benchmark/db_benchmark.ml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,25 @@ let all_benchmarks () =
5252
; test ~name:"multi_file_read" (module Multi_file_db) make_read_bench
5353
]
5454

55+
(* Filter benchmarks based on BENCHMARKS environment variable *)
56+
let filter_benchmarks benchmarks =
57+
match Sys.getenv "BENCHMARKS" with
58+
| None ->
59+
benchmarks
60+
| Some names_str ->
61+
let requested_names =
62+
String.split names_str ~on:','
63+
|> List.map ~f:String.strip |> String.Set.of_list
64+
in
65+
let filtered =
66+
List.filter benchmarks ~f:(fun bench ->
67+
String.Set.mem requested_names (Bench.Test.name bench) )
68+
in
69+
Printf.printf "Filtering benchmarks: running %d of %d\n"
70+
(List.length filtered) (List.length benchmarks) ;
71+
Printf.printf " Requested: %s\n" names_str ;
72+
filtered
73+
5574
(* Main entry point *)
5675
let () =
5776
(* Print configuration *)
@@ -65,4 +84,5 @@ let () =
6584
Printf.printf "\n" ;
6685

6786
(* Run benchmarks *)
68-
Command.run (Bench.make_command (all_benchmarks ()))
87+
let benchmarks = all_benchmarks () |> filter_benchmarks in
88+
Command.run (Bench.make_command benchmarks)

0 commit comments

Comments
 (0)