1 .\"**************************************************************************
2 .\"* *
3 .\"* OCaml *
4 .\"* *
5 .\"* Xavier Leroy, projet Cristal, INRIA Rocquencourt *
6 .\"* *
7 .\"* Copyright 1996 Institut National de Recherche en Informatique et *
8 .\"* en Automatique. *
9 .\"* *
10 .\"* All rights reserved. This file is distributed under the terms of *
11 .\"* the GNU Lesser General Public License version 2.1, with the *
12 .\"* special exception on linking described in the file LICENSE. *
13 .\"* *
14 .\"**************************************************************************
15 .\"
16 .TH "OCAMLCP" 1
17
18 .SH NAME
19 ocamlcp, ocamloptp \- The OCaml profiling compilers
20
21 .SH SYNOPSIS
22 .B ocamlcp
23 [
24 .I ocamlc options
25 ]
26 [
27 .BI \-P \ flags
28 ]
29 .I filename ...
30
31 .B ocamloptp
32 [
33 .I ocamlopt options
34 ]
35 [
36 .BI \-P \ flags
37 ]
38 .I filename ...
39
40 .SH DESCRIPTION
41 The
42 .B ocamlcp
43 and
44 .B ocamloptp
45 commands are front-ends to
46 .BR ocamlc (1)
47 and
48 .BR ocamlopt (1)
49 that instrument the source code, adding code to record how many times
50 functions are called, branches of conditionals are taken, etc.
51 Execution of instrumented code produces an execution profile in the
52 file ocamlprof.dump, which can be read using
53 .BR ocamlprof (1).
54
55 .B ocamlcp
56 accepts the same arguments and options as
57 .BR ocamlc (1)
58 and
59 .B ocamloptp
60 accepts the same arguments and options as
61 .BR ocamlopt (1).
62 There is only one exception: in both cases, the
63 .B \-pp
64 option is not supported. If you need to preprocess your source files,
65 you will have to do it separately before calling
66 .B ocamlcp
67 or
68 .BR ocamloptp .
69
70 .SH OPTIONS
71
72 In addition to the
73 .BR ocamlc (1)
74 or
75 .BR ocamlopt (1)
76 options,
77 .B ocamlcp
78 and
79 .B ocamloptp
80 accept one option to control the kind of profiling information, the
81 .BI \-P \ letters
82 option. The
83 .I letters
84 indicate which parts of the program should be profiled:
85 .TP
86 .B a
87 all options
88 .TP
89 .B f
90 function calls : a count point is set at the beginning of each function body
91 .TP
92 .B i
93 .BR if \ ... \ then \ ... \ else :
94 count points are set in both
95 .BR then \ and \ else
96 branches
97 .TP
98 .B l
99 .BR while , \ for
100 loops: a count point is set at the beginning of the loop body
101 .TP
102 .B m
103 .B match
104 branches: a count point is set at the beginning of the
105 body of each branch of a pattern-matching
106 .TP
107 .B t
108 .BR try \ ... \ with
109 branches: a count point is set at the beginning of the body of each
110 branch of an exception catcher
111
112 .PP
113 For instance, compiling with
114 .B ocamlcp \-P film
115 profiles function calls,
116 .BR if \ ... \ then \ ... \ else \ ...,
117 loops, and pattern matching.
118
119 Calling
120 .BR ocamlcp (1)
121 or
122 .BR ocamloptp (1)
123 without the
124 .B \-P
125 option defaults to
126 .BR \-P\ fm ,
127 meaning that only function calls and pattern matching are profiled.
128
129 Note: for compatibility with previous versions,
130 .BR ocamlcp (1)
131 also accepts the option
132 .B \-p
133 with the same argument and meaning as
134 .BR \-P .
135
136 .SH SEE ALSO
137 .BR ocamlc (1),
138 .BR ocamlopt (1),
139 .BR ocamlprof (1).
140 .br
141 .IR "The OCaml user's manual" ,
142 chapter "Profiling".
143