Skip to content

Commit b84c919

Browse files
committed
Driver: use the list of odoc units to count the max stats
1 parent 2c6cc0d commit b84c919

File tree

4 files changed

+19
-40
lines changed

4 files changed

+19
-40
lines changed

src/driver/compile.ml

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,24 @@ let mk_byhash (pkgs : Odoc_unit.intf Odoc_unit.unit list) =
99
| `Intf { hash; _ } -> Util.StringMap.add hash u acc)
1010
Util.StringMap.empty pkgs
1111

12-
let init_stats (pkgs : Packages.t Util.StringMap.t) =
12+
let init_stats (units : Odoc_unit.t list) =
1313
let total, total_impl, non_hidden, mlds =
14-
Util.StringMap.fold
15-
(fun _pkg_name pkg acc ->
16-
let tt, ti, nh, md =
17-
List.fold_left
18-
(fun (tt, ti, nh, md) (lib : Packages.libty) ->
19-
List.fold_left
20-
(fun (total, total_impl, non_hidden, mlds)
21-
(m : Packages.modulety) ->
22-
let total = total + 1 in
23-
let total_impl =
24-
match m.m_impl with
25-
| Some impl -> (
26-
match impl.mip_src_info with
27-
| Some _ -> total_impl + 1
28-
| None -> total_impl)
29-
| None -> total_impl
30-
in
31-
let non_hidden =
32-
if m.m_hidden then non_hidden else non_hidden + 1
33-
in
34-
(total, total_impl, non_hidden, mlds))
35-
(tt, ti, nh, md) lib.modules)
36-
acc pkg.Packages.libraries
14+
List.fold_left
15+
(fun (total, total_impl, non_hidden, mlds) (unit : Odoc_unit.t) ->
16+
let total = match unit.kind with `Intf _ -> total + 1 | _ -> total in
17+
let total_impl =
18+
match unit.kind with `Impl _ -> total_impl + 1 | _ -> total_impl
19+
in
20+
let non_hidden =
21+
match unit.kind with
22+
| `Intf { hidden = false; _ } -> non_hidden + 1
23+
| _ -> non_hidden
3724
in
38-
(tt, ti, nh, md + List.length pkg.Packages.mlds))
39-
pkgs (0, 0, 0, 0)
25+
let mlds = match unit.kind with `Mld -> mlds + 1 | _ -> mlds in
26+
(total, total_impl, non_hidden, mlds))
27+
(0, 0, 0, 0) units
4028
in
29+
4130
Atomic.set Stats.stats.total_units total;
4231
Atomic.set Stats.stats.total_impls total_impl;
4332
Atomic.set Stats.stats.non_hidden_units non_hidden;

src/driver/compile.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
type compiled
22

3-
val init_stats : Packages.set -> unit
3+
val init_stats : Odoc_unit.t list -> unit
44

55
val compile :
66
?partial:Fpath.t ->

src/driver/indexes.ml

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/driver/odoc_driver.ml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ let render_stats env nprocs =
470470
++ dline "Linking" non_hidden
471471
++ dline "Linking impls" total_impls
472472
++ dline "Linking mlds" total_mlds
473-
++ dline "Indexes" 10000
473+
++ dline "Indexes" 10000 (* TODO *)
474474
++ dline "HTML" (total_impls + non_hidden + total_mlds)
475475
++ line (procs nprocs))
476476
(fun comp compimpl compmld link linkimpl linkmld indexes html procs ->
@@ -537,7 +537,6 @@ let run libs verbose packages_dir odoc_dir odocl_dir html_dir stats nb_workers
537537
| _ -> failwith "Error, expecting singleton library in voodoo mode"
538538
else None
539539
in
540-
Compile.init_stats all;
541540
let () =
542541
Eio.Fiber.both
543542
(fun () ->
@@ -546,6 +545,7 @@ let run libs verbose packages_dir odoc_dir odocl_dir html_dir stats nb_workers
546545
Odoc_unit.of_packages ~output_dir:odoc_dir ~linked_dir:odocl_dir
547546
~index_dir:None all
548547
in
548+
Compile.init_stats all;
549549
let compiled =
550550
Compile.compile ?partial ~partial_dir:odoc_dir ?linked_dir:odocl_dir
551551
all
@@ -559,10 +559,7 @@ let run libs verbose packages_dir odoc_dir odocl_dir html_dir stats nb_workers
559559

560560
Format.eprintf "Final stats: %a@.%!" Stats.pp_stats Stats.stats;
561561
Format.eprintf "Total time: %f@.%!" (Stats.total_time ());
562-
if stats then Stats.bench_results html_dir;
563-
let indexes = Util.StringMap.map (fun _i pkg -> Indexes.package pkg) all in
564-
565-
ignore indexes
562+
if stats then Stats.bench_results html_dir
566563

567564
let fpath_arg =
568565
let print ppf v = Fpath.pp ppf v in

0 commit comments

Comments
 (0)