diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-10-11 08:16:34 -0700 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-10-11 08:16:34 -0700 |
commit | ffe5e166880e8148654ad6e5c373466508dfd4d9 (patch) | |
tree | 48655d298e43539d6a3046a3fb8d03fb4996be27 /CONTRIBUTING.md | |
parent | d22f6d73ff32080ad43c9e474b382e1578382b23 (diff) |
add profiling guide to contributor docs
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) |