OCAMLCP(1)
π NAME π
ocamlcp, ocamloptp β the OCaml profiling compilers, aka the besties who count everything your code does π΅οΈβοΈβ¨
πΈ SYNOPSIS πΈ
ocamlcp [ ocamlc options ] [ -P flags ] filename ...
ocamloptp [ ocamlopt options ] [ -P flags ] filename ...
π¦ DESCRIPTION π¦
okay so picture this: ocamlcp and ocamloptp are literally front-ends to ocamlc(1) and ocamlopt(1) π They take your source code and instrument it β meaning they sneak in little extra bits of code that keep track of how many times functions get called, how many times each branch of a conditional gets taken, etc. π
Then when you actually run that instrumented code, it spits out an execution profile into the file ocamlprof.dump, and you can read that whole thing with ocamlprof(1). It's giving data. It's giving receipts. π
Here's the tea though: ocamlcp accepts the exact same arguments and options as ocamlc(1), and ocamloptp accepts the exact same arguments and options as ocamlopt(1). One single exception and I need you to hear me on this:
the -pp option is not supported. nope. not happening. π
If you need to preprocess your source files, bestie you're gonna have to do that separately before you call ocamlcp or ocamloptp. no shortcuts, no cap. π
β¨ OPTIONS β¨
So on top of all the ocamlc(1) or ocamlopt(1) options (all of them, yes, all), ocamlcp and ocamloptp take one extra option to control what kind of profiling info you want: the -P letters option. The letters tell the compiler which parts of the program should get profiled π
aβ all options. everything. the whole vibe. π₯fβ function calls: a count point gets set at the beginning of each function bodyiβif ... then ... else ...: count points get set in both thethenand theelsebrancheslβwhile,forloops: a count point gets set at the beginning of the loop bodymβ match branches: a count point gets set at the beginning of the body of each branch of a pattern-matchingtβtry ... withbranches: a count point gets set at the beginning of the body of each branch of an exception catcher
for instance, compiling with ocamlcp -P film profiles function calls, if ... then ... else ..., loops, and pattern matching. iconic combo honestly π
If you call ocamlcp(1) or ocamloptp(1) with no -P option at all, it defaults to -P fm β meaning only function calls and pattern matching get profiled. that's it. that's the default. lowkey minimal but we respect it π«Ά
Note: for compatibility with previous versions,ocamlcp(1)also accepts the option-pwith the same argument and meaning as-P. yes, lowercase. yes, it's the same thing. we love a legacy moment π
π SEE ALSO π
ocamlc(1)ocamlopt(1)ocamlprof(1)- The OCaml user's manual, chapter "Profiling"
and that's the whole page bestie, no crumbs left π this lil legend came straight outta the General Commands Manual β OCAMLCP(1), the OCaml profiling compilers themselves β¨ go forth and profile, you absolute main character ππΈ
π¦ where this page comes from
- alpine 3.22: ocaml5-doc 5.3.0-r0 Β· LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
- alpine 3.23: ocaml5-doc 5.4.0-r0 Β· LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
- alpine 3.24: ocaml5-doc 5.4.1-r0 Β· LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- centos-stream 10: ocaml-docs 5.2.0-5.el10 Β· LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
- debian trixie: ocaml 5.3.0-3 Β· LGPL-2.1-OCaml
- fedora 43: ocaml-docs 5.3.0-4.fc43 Β· LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
- fedora 44: ocaml-docs 5.4.0-2.fc44 Β· LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
- nixos 26.05: ber-metaocaml 153
- nixos 26.05: ocaml 5.4.1
- nixpkgs unstable: ber-metaocaml 153
- nixpkgs unstable: ocaml 5.5.1
- nixpkgs unstable: ocaml-solo5 1.3.5
- ubuntu questing: ocaml 5.3.0-3
- ubuntu resolute: ocaml 5.4.0-3ubuntu1 Β· LGPL-2.1-OCaml
- ubuntu stonking: ocaml 5.4.1-1ubuntu1 Β· LGPL-2.1-OCaml
- Copyright 1996 Institut National de Recherche en Informatique et
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms