Home Explore Blog CI



nushell

1st chunk of `commands/docs/debug_profile.md`
e96663a5a65af7522ca1e918ae2477291bfa261459dfcc9000000001000009c4
---
title: debug profile
categories: |
  debug
version: 0.104.0
debug: |
  Profile pipeline elements in a closure.
usage: |
  Profile pipeline elements in a closure.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `debug profile` for [debug](/commands/categories/debug.md)

<div class='command-title'>Profile pipeline elements in a closure.</div>

## Signature

```> debug profile {flags} (closure)```

## Flags

 -  `--spans, -s`: Collect spans of profiled elements
 -  `--expand-source, -e`: Collect full source fragments of profiled elements
 -  `--values, -v`: Collect pipeline element output values
 -  `--lines, -l`: Collect line numbers
 -  `--duration-values, -d`: Report instruction duration as duration values rather than milliseconds
 -  `--max-depth, -m {int}`: How many blocks/closures deep to step into (default 2)

## Parameters

 -  `closure`: The closure to profile.


## Input/output types:

| input | output |
| ----- | ------ |
| any   | table  |
## Examples

Profile config evaluation
```nu
> debug profile { source $nu.config-path }

```

Profile config evaluation with more granularity
```nu
> debug profile { source $nu.config-path } --max-depth 4

```

## Notes
The profiler profiles every evaluated instruction inside a closure, stepping into all
commands calls and other blocks/closures.

The output can be heavily customized. By default, the following columns are included:
- depth       : Depth of the instruction. Each entered block adds one level of depth. How many
                blocks deep to step into is controlled with the --max-depth option.
- id          : ID of the instruction
- parent_id   : ID of the instruction that created the parent scope
- source      : Source code that generated the instruction. If the source code has multiple lines,
                only the first line is used and `...` is appended to the end. Full source code can
                be shown with the --expand-source flag.
- pc          : The index of the instruction within the block.
- instruction : The pretty printed instruction being evaluated.
- duration    : How long it took to run the instruction.
- (optional) span        : Span associated with the instruction. Can be viewed via the `view span`
                           command. Enabled with the --spans flag.
- (optional) output      : The output value of the instruction. Enabled with the --values flag.

Title: debug profile
Summary
The `debug profile` command profiles pipeline elements within a closure. It allows for detailed analysis of instruction execution, including duration, source code, and output values. Flags control the level of detail, such as span collection, full source expansion, output value capture, and maximum depth of block stepping.