diff options
Diffstat (limited to 'CONTRIBUTING.md')
-rw-r--r-- | CONTRIBUTING.md | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 38bc30eda..53b6f47b1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -132,6 +132,34 @@ If you want to trigger a debug session from VSCode, you can use the following sn } ``` +## Profiling + +If you want to investigate what's contributing to CPU usage you can add the following to the top of the `main()` function in `main.go` + +```go +import "runtime/pprof" + +func main() { + f, err := os.Create("cpu.prof") + if err != nil { + log.Fatal("could not create CPU profile: ", err) + } + defer f.Close() + if err := pprof.StartCPUProfile(f); err != nil { + log.Fatal("could not start CPU profile: ", err) + } + defer pprof.StopCPUProfile() + ... +``` + +Then run lazygit, and afterwards, from your terminal, run: + +```sh +go tool pprof --web cpu.prof +``` + +That should open an application which allows you to view the breakdown of CPU usage. + ## Testing Lazygit has two kinds of tests: unit tests and integration tests. Unit tests go in files that end in `_test.go`, and are written in Go. For integration tests, see [here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md) |