Skip to content

Commit

Permalink
Stat benchmark: report cleanup time too
Browse files Browse the repository at this point in the history
  • Loading branch information
talex5 committed Feb 14, 2024
1 parent 43bd3b8 commit 174a093
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 14 additions & 2 deletions bench/bench_stat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ let run_bench ~n ~levels ~random ~root ~clock =
let t1 = Eio.Time.now clock in
t1 -. t0
in
traceln "Created %i files and directories in %.2f s" (Bench_dir.size dir) create_time;
traceln "Created in %.2f s" create_time;
let bench () =
Gc.full_major ();
let stat0 = Gc.stat () in
Expand All @@ -136,11 +136,23 @@ let run_bench ~n ~levels ~random ~root ~clock =
| _ -> failwith "Stat not the same as the spec"
in
let time, minor, major = bench () in
traceln "Statted in %.2f s" time;
let remove_time =
let t0 = Eio.Time.now clock in
Eio.Path.read_dir root
|> List.iter (fun item ->
Eio.Path.rmtree (root / item)
);
let t1 = Eio.Time.now clock in
t1 -. t0
in
traceln "Removed in %.2f s" remove_time;
[
Metric.create "create-time" (`Float (1e3 *. create_time)) "ms" (Fmt.str "Time to create %i files and directories" (Bench_dir.size dir));
Metric.create "stat-time" (`Float (1e3 *. time)) "ms" (Fmt.str "Time to stat %i files and directories" (Bench_dir.size dir));
Metric.create "stat-minor" (`Float (1e-3 *. minor)) "kwords" (Fmt.str "Minor words allocated to stat %i files and directories" (Bench_dir.size dir));
Metric.create "stat-major" (`Float (1e-3 *. major)) "kwords" (Fmt.str "Major words allocated %i files and directories" (Bench_dir.size dir))
Metric.create "stat-major" (`Float (1e-3 *. major)) "kwords" (Fmt.str "Major words allocated %i files and directories" (Bench_dir.size dir));
Metric.create "remove-time" (`Float (1e3 *. remove_time)) "ms" "Time to remove everything";
]

let run env =
Expand Down
5 changes: 4 additions & 1 deletion bench/main.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
open Eio.Std

let benchmarks = [
"Promise", Bench_promise.run;
"Cancel", Bench_cancel.run;
Expand All @@ -22,6 +24,7 @@ let usage_error () =

let () =
Eio_main.run @@ fun env ->
traceln "Using %s backend" env#backend_id;
let benchmarks =
match Array.to_list Sys.argv with
| [_] -> benchmarks
Expand All @@ -35,7 +38,7 @@ let () =
| _ -> usage_error ()
in
let run (name, fn) =
Eio.traceln "Running %s..." name;
traceln "Running %s..." name;
let metrics = fn env in
`Assoc [
"name", `String name;
Expand Down

0 comments on commit 174a093

Please sign in to comment.