Skip to content

Commit b17477e

Browse files
committed
fix timing statistics
1 parent be53efe commit b17477e

File tree

3 files changed

+39
-13
lines changed

3 files changed

+39
-13
lines changed

src/state/state.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type t = {
2222
goblint : GvGoblint.solver_state;
2323
warnings : GvMessages.t;
2424
meta : Yojson.Safe.t;
25-
stats : Stats.t * Gc.stat;
25+
stats : Timing.tree * Gc.stat;
2626
file_loc : (string, string) Hashtbl.t;
2727
display : display option;
2828
inspect : inspect option;
@@ -37,7 +37,7 @@ let default =
3737
goblint = GvGoblint.empty;
3838
warnings = [];
3939
meta = `Null;
40-
stats = (Stats.top, Gc.quick_stat ());
40+
stats = (Timing.create_tree "default", Gc.quick_stat ());
4141
file_loc = Hashtbl.create 113;
4242
display = None;
4343
inspect = None;

src/state/timing.ml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
(** Timing tree node. *)
3+
type tree = {
4+
name: string; (** Name of node. *)
5+
mutable cputime: float; (** Accumulated CPU time in seconds. *)
6+
mutable walltime: float; (** Accumulated wall time in seconds. *)
7+
mutable allocated: float; (** Accumulated allocated memory in bytes. *)
8+
mutable count: int; (** Number of repetitions. Only set if {!Timing.countCalls} is true. *)
9+
mutable children: tree list; (** Child nodes. *)
10+
}
11+
12+
let create_tree name =
13+
{
14+
name = name;
15+
cputime = 0.0;
16+
walltime = 0.0;
17+
allocated = 0.0;
18+
count = 0;
19+
children = [];
20+
}

src/ui/panel/gvStatisticsView.re

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
open Batteries;
2-
module Stats = GoblintCil.Stats;
32

43
let rec make_task_list = tasks =>
54
if (List.is_empty(tasks)) {
65
React.null;
76
} else {
87
<ul>
98
{tasks
10-
|> List.mapi((i, task: Stats.t) => {
9+
|> List.mapi((i, task: Timing.tree) => {
1110
let key = string_of_int(i);
1211
<li key>
1312
{task.name
1413
++ ": "
15-
++ string_of_float(task.time)
14+
++ string_of_float(task.cputime)
1615
++ " s"
1716
|> React.string}
18-
{task.sub |> List.rev |> make_task_list}
17+
{task.children |> List.rev |> make_task_list}
1918
</li>;
2019
})
2120
|> React.list}
@@ -26,16 +25,23 @@ let as_megabytes = words => Printf.sprintf("%.2f MB", words /. 131072.0);
2625

2726
[@react.component]
2827
let make = (~stats) => {
29-
let (time: Stats.t, gc: Gc.stat) = stats;
28+
let (time: Timing.tree, gc: Gc.stat) = stats;
3029
let total =
31-
time.sub |> List.fold_left((acc, sub: Stats.t) => acc +. sub.time, 0.0);
30+
time.children |> List.fold_left((acc, sub: Timing.tree) => acc +. sub.cputime, 0.0);
3231

3332
<div>
34-
<span>
33+
{if(total == 0.) {
34+
<div className="bg-warning">
35+
{"For timing statistics the analysis has to be run with -v (alternatively, either option dbg.verbose or dbg.timing.enabled can be activated)" |> React.string}
36+
</div>;
37+
} else {
38+
React.null
39+
}}
40+
<div>
3541
{"Total: " ++ string_of_float(total) ++ " s" |> React.string}
36-
</span>
37-
{time.sub |> List.rev |> make_task_list}
38-
<span>
42+
</div>
43+
{time.children |> List.rev |> make_task_list}
44+
<div>
3945
{Printf.sprintf(
4046
"Memory: total=%s, max=%s, minor=%s, major=%s, promoted=%s, minor collections=%d, major collections=%d, compactions=%d",
4147
as_megabytes(gc.minor_words +. gc.major_words -. gc.promoted_words),
@@ -48,6 +54,6 @@ let make = (~stats) => {
4854
gc.compactions,
4955
)
5056
|> React.string}
51-
</span>
57+
</div>
5258
</div>;
5359
};

0 commit comments

Comments
 (0)