From b8c40861f30ddee7f7818950a4e18cfec31ea645 Mon Sep 17 00:00:00 2001 From: rand00 Date: Wed, 15 Dec 2021 23:09:23 +0100 Subject: [PATCH] Builder_web.job_build_treemap: Implementing partitioning of Info tree --- lib/builder_web.ml | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/builder_web.ml b/lib/builder_web.ml index b688f88..8bc15ad 100644 --- a/lib/builder_web.ml +++ b/lib/builder_web.ml @@ -212,13 +212,28 @@ let add_routes datadir = m "Error reading ELF file %a" Fpath.pp path)) >>= fun infos -> let svg_html = - infos - |> Info.import - |> Info.diff_size - |> Info.prefix_filename - |> Info.cut 2 + let info, excluded = + let size, info = + infos + |> Info.import + |> Info.diff_size_tree + in + (*> Note: this heuristic fails if one has all subtrees of equal size*) + let node_big_enough subtree = + match Info.(subtree.T.value.size) with + | None -> true + | Some subtree_size -> + let pct = Int64.(to_float subtree_size /. to_float size) in + pct > 0.05 + in + info + |> Info.prefix_filename + |> Info.cut 2 + |> Info.partition_subtrees node_big_enough + in + info |> Treemap.of_tree - |> Treemap.to_html_with_scale ~binary_size + |> Treemap.to_html_with_scale ~binary_size (*goto add 'excluded' via some new param*) |> Fmt.to_to_string (Tyxml.Html.pp ()) (* |> Treemap.svg * |> Fmt.to_to_string (Tyxml.Svg.pp ()) *)