Skip to content

Commit

Permalink
Test a flame graph example; fix previous commit test exp.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukstafi committed Mar 20, 2024
1 parent a58112a commit cfcc872
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 1 deletion.
10 changes: 10 additions & 0 deletions test/debugger_sexp_html-toc.expected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div><div><div><a href="./debugger_sexp_html.html#1"><div>&quot;test/test_debug_html.ml&quot;:9:19: foo</div></a></div><ul><li><div><a href="./debugger_sexp_html.html#2"><div>&quot;test/test_debug_html.ml&quot;:10:6: y</div></a></div></li></ul></div></div>

<div><div><div><a href="./debugger_sexp_html.html#3"><div>&quot;test/test_debug_html.ml&quot;:17:19: bar</div></a></div><ul><li><div><a href="./debugger_sexp_html.html#4"><div>&quot;test/test_debug_html.ml&quot;:18:6: y</div></a></div></li></ul></div></div>

<div><div><div><a href="./debugger_sexp_html.html#5"><div>&quot;test/test_debug_html.ml&quot;:23:19: baz</div></a></div><ul><li><div><a href="./debugger_sexp_html.html#6"><div>&quot;test/test_debug_html.ml&quot;:24:17: _yz</div></a></div></li><li><div><a href="./debugger_sexp_html.html#7"><div>&quot;test/test_debug_html.ml&quot;:25:17: _uw</div></a></div></li></ul></div></div>

<div><div><div><a href="./debugger_sexp_html.html#8"><div>&quot;test/test_debug_html.ml&quot;:30:19: lab</div></a></div><ul><li><div><a href="./debugger_sexp_html.html#9"><div>&quot;test/test_debug_html.ml&quot;:31:6: y</div></a></div></li></ul></div></div>

<div><div><div><a href="./debugger_sexp_html.html#10"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#11"><div>&quot;test/test_debug_html.ml&quot;:40:8: y</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#12"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#13"><div>&quot;test/test_debug_html.ml&quot;:40:8: y</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#14"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#15"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#16"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><a href="./debugger_sexp_html.html#17"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div></li></ul></div></li></ul></div></li></ul></div></li></ul></div></li><li><div><div><a href="./debugger_sexp_html.html#18"><div>&quot;test/test_debug_html.ml&quot;:41:8: z</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#19"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#20"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#21"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><a href="./debugger_sexp_html.html#22"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div></li></ul></div></li></ul></div></li></ul></div></li></ul></div></li></ul></div></li></ul></div></li><li><div><div><a href="./debugger_sexp_html.html#23"><div>&quot;test/test_debug_html.ml&quot;:41:8: z</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#24"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#25"><div>&quot;test/test_debug_html.ml&quot;:40:8: y</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#26"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#27"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#28"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><a href="./debugger_sexp_html.html#29"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div></li></ul></div></li></ul></div></li></ul></div></li></ul></div></li><li><div><div><a href="./debugger_sexp_html.html#30"><div>&quot;test/test_debug_html.ml&quot;:41:8: z</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#31"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#32"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><div><a href="./debugger_sexp_html.html#33"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div><ul><li><div><a href="./debugger_sexp_html.html#34"><div>&quot;test/test_debug_html.ml&quot;:36:24: loop</div></a></div></li></ul></div></li></ul></div></li></ul></div></li></ul></div></li></ul></div></li></ul></div></li></ul></div></div>

2 changes: 1 addition & 1 deletion test/test_debug_html.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ open Sexplib0.Sexp_conv

module Debug_runtime =
(val Minidebug_runtime.debug_file ~hyperlink:"../" ~toc_specific_hyperlink:"./"
~with_table_of_contents:true
~with_toc_listing:true
~backend:(`Html PrintBox_html.Config.(tree_summary true default))
"debugger_sexp_html")

Expand Down
107 changes: 107 additions & 0 deletions test/test_expect_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3554,3 +3554,110 @@ let%expect_test "%log_entry" =
│ └─"log 4"
└─"postscript"
|}]

let%expect_test "flame graph" =
let module Debug_runtime =
(val Minidebug_runtime.debug_file ~hyperlink:"../" ~toc_specific_hyperlink:"./"
~toc_flame_graph:true
~backend:(`Html PrintBox_html.Config.(tree_summary true default))
"test_expect_test_flame_graph")
in
let%debug_show rec loop (depth : int) (x : t) : int =
if depth > 4 then x.first + x.second
else if depth > 1 then loop (depth + 1) { first = x.second + 1; second = x.first / 2 }
else
let y : int = loop (depth + 1) { first = x.second - 1; second = x.first + 2 } in
let z : int = loop (depth + 1) { first = x.second + 1; second = y } in
z + 7
in
let () = ignore @@ loop 0 { first = 7; second = 42 } in
let file = open_in "test_expect_test_flame_graph-toc.html" in
(try
while true do
print_endline @@ input_line file
done
with End_of_file -> ());
close_in file;
let output = [%expect.output] in
let output =
Str.global_replace
(Str.regexp
{|[0-9]+\.[0-9][0-9][0-9]+|})
"N.NNNN" output
in
print_endline output;
[%expect {|
<div style="position: relative; height: 0px;"><div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #d7ead6;"><div><div><a href="./test_expect_test_flame_graph.html#1"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #d3d5bb;"><div><div><a href="./test_expect_test_flame_graph.html#2"><div>&quot;test/test_expect_test.ml&quot;:3569:10: y</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #9995ab;"><div><div><a href="./test_expect_test_flame_graph.html#3"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #d7cbd7;"><div><div><a href="./test_expect_test_flame_graph.html#4"><div>&quot;test/test_expect_test.ml&quot;:3569:10: y</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #ad8fc7;"><div><div><a href="./test_expect_test_flame_graph.html#5"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #d9ebd5;"><div><div><a href="./test_expect_test_flame_graph.html#6"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #ede9d9;"><div><div><a href="./test_expect_test_flame_graph.html#7"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #ebebd3;"><div><div><a href="./test_expect_test_flame_graph.html#8"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div></div></div>
</div></div>
</div></div>
</div></div>
</div></div>
<div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #a8a395;"><div><div><a href="./test_expect_test_flame_graph.html#9"><div>&quot;test/test_expect_test.ml&quot;:3570:10: z</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #e1cae6;"><div><div><a href="./test_expect_test_flame_graph.html#10"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #96a7a7;"><div><div><a href="./test_expect_test_flame_graph.html#11"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #e5c894;"><div><div><a href="./test_expect_test_flame_graph.html#12"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #c3dfaf;"><div><div><a href="./test_expect_test_flame_graph.html#13"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div></div></div>
</div></div>
</div></div>
</div></div>
</div></div>
</div></div>
</div></div>
<div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #b0b9d7;"><div><div><a href="./test_expect_test_flame_graph.html#14"><div>&quot;test/test_expect_test.ml&quot;:3570:10: z</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #94b4b8;"><div><div><a href="./test_expect_test_flame_graph.html#15"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #edcfc5;"><div><div><a href="./test_expect_test_flame_graph.html#16"><div>&quot;test/test_expect_test.ml&quot;:3569:10: y</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #cae9b1;"><div><div><a href="./test_expect_test_flame_graph.html#17"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #e6eaee;"><div><div><a href="./test_expect_test_flame_graph.html#18"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #b8bca8;"><div><div><a href="./test_expect_test_flame_graph.html#19"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #959298;"><div><div><a href="./test_expect_test_flame_graph.html#20"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div></div></div>
</div></div>
</div></div>
</div></div>
</div></div>
<div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #a498dc;"><div><div><a href="./test_expect_test_flame_graph.html#21"><div>&quot;test/test_expect_test.ml&quot;:3570:10: z</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #949290;"><div><div><a href="./test_expect_test_flame_graph.html#22"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #c0d6e8;"><div><div><a href="./test_expect_test_flame_graph.html#23"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #f0e2b2;"><div><div><a href="./test_expect_test_flame_graph.html#24"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div><div style="position: relative; top:10%; height: 90%; left:N.NNNN%; width:N.NNNN%;">
<div style="position: relative; top: 0%; width: 100%; height: 100%;"><div style="position: relative; top: 0px; left: 0px; width: 100%; background: #919ce2;"><div><div><a href="./test_expect_test_flame_graph.html#25"><div>&quot;test/test_expect_test.ml&quot;:3565:26: loop</div></a></div></div>
</div></div></div>
</div></div>
</div></div>
</div></div>
</div></div>
</div></div>
</div></div>
</div></div><div style="height: 320px;"></div> |}]

0 comments on commit cfcc872

Please sign in to comment.