Skip to content

Add ProfileFilename #53

Description

@josharian

Every time I use this package, I think that I can do something like:

var flagCPUProfile = flag.String("cpuprofile", "", "write a cpuprofile to `cpuprofile`")

func main() {
	if *flagCPUProfile != "" {
		defer profile.Start(profile.ProfilePath(*flagCPUProfile)).Stop()
	}

And then I run the program with -cpuprofile=somename.pprof. And there is no profile to be found.

And then I dig through the docs and discover ProfilePath is supposed to be a directory. And then I wish there was a way to provide a filename. This is because I sometimes do multiple runs, and I want to write the results to different profiles so that I can combine them, and I don't want to have to deal with creating and cleaning up a directory per profile.

May I send a PR to add ProfileFilename, or something like it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions