profile sync_or_async message f measures the time taken to run f, and outputs the result. Nested calls to profile are displayed as a tree. Use Async to profile Async code. It is safe to nest calls to profile inside calls to profile Async. profile Async does have some restrictions in order to get valid results:
a nested call to profile Async must exit before its parent does
there cannot be multiple sibling calls to profile Async running concurrently
val am_forcing_message : unit -> bool
am_forcing_message () returns true when profiling is calling force on a message supplied to profile. This is useful if you want to have a sexp_of_t function behave differently when producing messages.
Return the current stack of profile messages, sorted inner profile frames first. Returns None if should_profile is false.
val disown : (unit ->'a)->'a
disown f runs f as though it were at top level, rather than whatever the current context is. In other words, it causes the parent (current) context to disown children created by f. This is useful for background jobs that might outlive their parents, since Nested_profile requires that parents wait for their children.