OCAMLPROF(1)

πŸ‘‘ OCAMLPROF β€” the OCaml profiler πŸ’…

okay so bestie, this is a page from the General Commands Manual, and it's all about ocamlprof, the profiler that tells you which of your functions are actually pulling their weight and which ones are just standing there. let's get into it 🫢


✨ NAME ✨

ocamlprof β€” The OCaml profiler. that's it, that's the whole vibe. it profiles. 🌸


✨ SYNOPSIS ✨

ocamlprof [ options ] filename ...

✨ DESCRIPTION ✨

so here's the tea: the ocamlprof command prints out execution counts that got gathered while a OCaml program was running β€” but only if that program was instrumented with ocamlcp(1) first. no instrumentation, no counts, no tea. 😭

what it gives you is a source listing of the program modules you passed as arguments, except the execution counts are all up in there, inserted as comments. like, it's your own code but now it's self-reporting. main character behaviour fr fr.

for example:

ocamlprof foo.ml

prints the source code for the foo module, with comments showing how many times the functions in that module got called. ✨ iconic ✨

but listen β€” this info is only accurate if you haven't touched the source file since the profiling run happened. edit the file after and the counts are basically lying to you. ngl that's just how it is. πŸ™ˆ

✨ OPTIONS ✨

  • -f dumpfile β€” points at an alternate dump file of profiling information. default one not doing it for you? pick your own. πŸ’œ
  • -F string β€” adds an extra string to the profiling info that gets output. by default ocamlprof(1) annotates your programs with comments shaped like (* n *), where n is the counter value for a profiling point. pass -F s and the annotation becomes (* sn *). cute little prefix, slay. πŸŽ€
  • -impl filename β€” compiles the file filename as an implementation file, even if its extension isn't .ml. we don't judge files by their extensions here. πŸ’…
  • -intf filename β€” compiles the file filename as an interface file, even if its extension isn't .mli. same energy, different extension. 🌈
  • -keywords version+list β€” sets the keywords according to the version+list specification. yes, exactly as written. πŸ”₯
  • -version β€” prints the version string and dips. πŸ‘‹
  • -vnum β€” prints the short version number and dips. shorter. still dips. ✨
  • -help or --help β€” shows a short usage summary and dips. when you just need a lil refresher. πŸ¦‹

✨ SEE ALSO ✨

  • ocamlcp(1).
  • The OCaml user's manual, chapter "Profiling". go read it, iykyk πŸ“–

and that's the whole page, bestie!! this one came to you from the General Commands Manual, filed under OCAMLPROF(1) β€” and yeah, the footer is just OCAMLPROF(1) again with no date attached, so consider it timeless, like all the best icons. πŸ‘‘πŸ’–

go profile something and find out which function is lowkey doing nothing. periodt. πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from