This site is updated infrequently. For up-to-date information, please visit the new OCaml website at ocaml.org.

profiling
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
 Date: 2002-05-02 (20:16) From: bwv211mail Subject: profiling
```I tried the profiling example in the new Ocaml book, p.281ff. But I
am not getting any information that seems worthwhile. I hope someone
can help me...

\$ cat test.ml

let rec interval a b =
if b < a then []
else a :: (interval (a + 1) b)

let mult xx =
let rec f = function
| [] -> 1
| 0 :: _ -> raise Exit
| x :: xx -> x * f xx
in try f xx with Exit -> 0

let l1 = interval 1 30
let l2 = interval 31 61
let l3 = l1 @ (0 :: l2)

let _ =
for i = 0 to 100000 do
let _ = mult l1 in
let _ = mult l3 in
()
done;
print_int (mult l1); print_newline ();
print_int (mult l3); print_newline ()

\$ ocamlopt -p -o test test.ml
\$ ./test
-738197504
0
\$ gprof test > test.profile
\$ cat test.profile
[...]
% cumulative self self total
time seconds seconds calls ms/call ms/call name
82.2 1.23 1.23 .mcount (104)
17.8 1.49 0.27 1 265.62 265.62 init_dummy
<cycle 1> [3]
0.0 1.49 0.00 114 0.00 0.00 darken [6]
[...]

The book indicates that the mult procedure should show up - but all I
see is mcount... am I doing something wrong?

```