Skip to content

runtime/pprof: document the requirement to wait to capture any CPU profile samples #18504

@rakyll

Description

@rakyll

Package's godoc example starts the CPU profiling and defers pprof.StopCPUProfile, but it fails to document that the function need to spend sometime before returning in order for any samples to be collected. We might want to add a time.Sleep to make it more obvious and document it throughly that time is required to collect samples.

if err := pprof.StartCPUProfile(f); err != nil {
    log.Fatal("could not start CPU profile: ", err)
}
defer pprof.StopCPUProfile()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions