4 For all forms of <:Profiling:>, you can gather counts for all
5 functions on the stack, not just the currently executing function. To
6 do so, compile your program with `-profile-stack true`. For example,
7 suppose that `list-rev.sml` contains the following.
11 sys::[./bin/InclGitFile.py mlton master doc/examples/profiling/list-rev.sml]
14 Compile with stack profiling and then run the program.
16 % mlton -profile alloc -profile-stack true list-rev.sml
20 Display the profiling data.
22 % mlprof -show-line true list-rev mlmon.out
23 6,030,136 bytes allocated (108,336 bytes by GC)
25 ----------------------- ----- ----- ----
26 append list-rev.sml: 1 97.6% 97.6% 1.4%
28 <main> 0.4% 98.2% 1.8%
29 rev list-rev.sml: 6 0.2% 97.6% 1.8%
32 In the above table, we see that `rev`, defined on line 6 of
33 `list-rev.sml`, is only responsible for 0.2% of the allocation, but is
34 on the stack while 97.6% of the allocation is done by the user program
35 and while 1.8% of the allocation is done by the garbage collector.
37 The run-time performance impact of `-profile-stack true` can be
38 noticeable since there is some extra bookkeeping at every nontail call