ginkgo icon indicating copy to clipboard operation
ginkgo copied to clipboard

How to use pprof with ginkgo?

Open SamYuan1990 opened this issue 4 years ago • 5 comments

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?

SamYuan1990 avatar Aug 31 '21 14:08 SamYuan1990

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

SamYuan1990 avatar Aug 31 '21 14:08 SamYuan1990

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.

onsi avatar Aug 31 '21 14:08 onsi

thanks for the msg, and keep eye on v2~

SamYuan1990 avatar Aug 31 '21 14:08 SamYuan1990

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.

onsi avatar Aug 31 '21 14:08 onsi

The V2 beta was just released. Here are some instructions for trying it out.!

onsi avatar Sep 10 '21 19:09 onsi