---
title: "Profiling your zsh setup with zprof"
description: "Profiling your zsh setup with zprof"
canonical_url: "https://www.bigbinary.com/blog/zsh-profiling"
markdown_url: "https://www.bigbinary.com/blog/zsh-profiling.md"
---

# Profiling your zsh setup with zprof

Profiling your zsh setup with zprof

- Author: Sreeram Venkitesh
- Published: October 12, 2023
- Categories: Misc

While using frameworks like [oh-my-zsh](https://ohmyz.sh/) to upgrade your
shell, it is pretty easy to get carried away with all the available plugins.
This can eventually take a toll on your shell’s performance. One significant way
it can affect your workflow is by slowing everything down. The more items you
add to your `.zshrc` file, the more time your shell will need to start up.
Profiling your shell is a good start to figuring out what is slowing it down.

### zprof

[zprof](https://zsh.sourceforge.io/Doc/Release/Zsh-Modules.html#The-zsh_002fzprof-Module)
is a utility that comes packaged with zsh, which you can use to profile your zsh
script.

Add the following to the top of your `.zshrc` file to load zprof.

```bash
zmodload zsh/zprof
```

At the bottom of your `.zshrc`, add the following.

```bash
zprof
```

This would profile your zsh script and print a summary of all the commands run
during your shell startup and the time it takes to execute them. Run `exec zsh`
to apply the changes and restart your shell. Your shell will print something
like this:

![Output of the zprof command](https://www.bigbinary.com/blog/images/images_used_in_blog/2023/zsh-profiling/zprof-output.png)

With this you can see which commands are taking the most time to load. Enabling
profiling has helped pinpoint the issue and now you can look into fixing it. In
the above example, you can see that nvm is taking up a considerable amount of
time.

## Links

- [Human page](https://www.bigbinary.com/blog/zsh-profiling)
