summaryrefslogtreecommitdiff
path: root/man/ocamlcp.m
blob: d6c983d167ca81194c582d5d5cef76e300fddb4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
.\"**************************************************************************
.\"*                                                                        *
.\"*                                 OCaml                                  *
.\"*                                                                        *
.\"*             Xavier Leroy, projet Cristal, INRIA Rocquencourt           *
.\"*                                                                        *
.\"*   Copyright 1996 Institut National de Recherche en Informatique et     *
.\"*     en Automatique.                                                    *
.\"*                                                                        *
.\"*   All rights reserved.  This file is distributed under the terms of    *
.\"*   the GNU Lesser General Public License version 2.1, with the          *
.\"*   special exception on linking described in the file LICENSE.          *
.\"*                                                                        *
.\"**************************************************************************
.\"
.TH "OCAMLCP" 1

.SH NAME
ocamlcp, ocamloptp \- The OCaml profiling compilers

.SH SYNOPSIS
.B ocamlcp
[
.I ocamlc options
]
[
.BI \-P \ flags
]
.I filename ...

.B ocamloptp
[
.I ocamlopt options
]
[
.BI \-P \ flags
]
.I filename ...

.SH DESCRIPTION
The
.B ocamlcp
and
.B ocamloptp
commands are front-ends to
.BR ocamlc (1)
and
.BR ocamlopt (1)
that instrument the source code, adding code to record how many times
functions are called, branches of conditionals are taken, etc.
Execution of instrumented code produces an execution profile in the
file ocamlprof.dump, which can be read using
.BR ocamlprof (1).

.B ocamlcp
accepts the same arguments and options as
.BR ocamlc (1)
and
.B ocamloptp
accepts the same arguments and options as
.BR ocamlopt (1).
There is only one exception: in both cases, the
.B \-pp
option is not supported.  If you need to preprocess your source files,
you will have to do it separately before calling
.B ocamlcp
or
.BR ocamloptp .

.SH OPTIONS

In addition to the
.BR ocamlc (1)
or
.BR ocamlopt (1)
options,
.B ocamlcp
and
.B ocamloptp
accept one option to control the kind of profiling information, the
.BI \-P \ letters
option. The
.I letters
indicate which parts of the program should be profiled:
.TP
.B a
all options
.TP
.B f
function calls : a count point is set at the beginning of each function body
.TP
.B i
.BR if \ ... \ then \ ... \ else :
count points are set in both
.BR then \ and \ else
branches
.TP
.B l
.BR while , \ for
loops: a count point is set at the beginning of the loop body
.TP
.B m
.B match
branches: a count point is set at the beginning of the
body of each branch of a pattern-matching
.TP
.B t
.BR try \ ... \ with
branches: a count point is set at the beginning of the body of each
branch of an exception catcher

.PP
For instance, compiling with
.B ocamlcp \-P film
profiles function calls,
.BR if \ ... \ then \ ... \ else \ ...,
loops, and pattern matching.

Calling
.BR ocamlcp (1)
or
.BR ocamloptp (1)
without the
.B \-P
option defaults to
.BR \-P\ fm ,
meaning that only function calls and pattern matching are profiled.

Note: for compatibility with previous versions,
.BR ocamlcp (1)
also accepts the option
.B \-p
with the same argument and meaning as
.BR \-P .

.SH SEE ALSO
.BR ocamlc (1),
.BR ocamlopt (1),
.BR ocamlprof (1).
.br
.IR "The OCaml user's manual" ,
chapter "Profiling".