timeit for debug
Time how long it takes a closure to run.
Signature
> timeit {flags} (command)
Flags
--output, -o: Include the closure output.
Parameters
command: The closure to run.
Input/output types:
| input | output |
|---|---|
| any | duration |
| nothing | duration |
| any | record<time: duration, output: any> |
| nothing | record<time: duration, output: any> |
Examples
Time a closure containing one command
> timeit { sleep 500ms }
500ms 631µs 800nsTime a closure with an input value
> 'A really long string' | timeit { split chars }Time a closure with an input stream
> open some_file.txt | collect | timeit { split chars }Time a closure containing a pipeline
> timeit { open some_file.txt | split chars }Time a closure and also return the output
> timeit --output { 'example text' }
╭────────┬──────────────╮
│ time │ 14µs 328ns │
│ output │ example text │
╰────────┴──────────────╯Notes
Any pipeline input given to this command is passed to the closure. Note that streaming inputs may affect timing results, and it is recommended to add a collect command before this if the input is a stream.
This command will bubble up any errors encountered when running the closure. The return pipeline of the closure is collected into a value and then discarded if --output is not set.