How to use pprof with ginkgo?
as subject, I already use ginkgo as test framework and I want to use it together with pprof to further investigate/ensure there no performance issue for my code.
any suggestion?
ginkgo -r -v -cpuprofile ./cpu.prof -memprofile ./mem.prof
pprof -http=":8091" ./cpu.prof
./cpu.prof: open ./cpu.prof: no such file or directory
pprof: failed to fetch any source profiles
hey @SamYuan1990 there are a few issues with profiling in v1 that are fixed in v2 (which will release in the next couple of months). For now you can use go test though note that you will have to go test each individual package (go test has a limitation around profiling multiple packages at once). Good news is that in v2 Ginkgo supports running multi-package profiles and will put all your profiles in one spot.
One thing to note - I'm not sure how useful the -http parameter is. The tests aren't generally long-lived. I think your best bet is to dump out profiles as you run tests and then analyze them afterwards vs trying to connect to the running test process.
thanks for the msg, and keep eye on v2~
yes that go test behavior is what i was telling you about - it doesn't support profiling with multiple packages.
if you want you can start playing with v2 now. Just clone the ginkgo repo, git checkout v2, and point your go.mod to your local v2 copy and give the new Ginkgo a try! Note that you'll need to go install ./ginkgo to get the v2 cli on your path.
The V2 beta was just released. Here are some instructions for trying it out.!