OCAMLCP(1)

πŸ“¦
version 5.5.0 Β· 2 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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 body
  • i β€” if ... then ... else ...: count points get set in both the then and the else branches
  • l β€” while, for loops: a count point gets set at the beginning of the loop body
  • m β€” match branches: a count point gets set at the beginning of the body of each branch of a pattern-matching
  • t β€” try ... with branches: 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 -p with the same argument and meaning as -P. yes, lowercase. yes, it's the same thing. we love a legacy moment πŸ’œ

🌈 SEE ALSO 🌈


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