profile for debug

Profile each pipeline element in a closure.


> profile (closure) --source --values --max-depth


  • closure: the closure to run
  • --source (-): Collect source code in the report
  • --values (-): Collect values in the report
  • --max-depth {int}: How many levels of blocks to step into (default: 1)


The command collects run time of every pipeline element, recursively stepping into child closures until a maximum depth. Optionally, it also collects the source code and intermediate values.

Current known limitations are:

  • profiling data from subexpressions is not tracked
  • it does not step into loop iterations


Profile some code, stepping into the spam command and collecting source.

> def spam [] { "spam" }; profile {|| spam | str length } -d 2 --source