go.runtime.pprof
1.23.1.3
dotnet add package go.runtime.pprof --version 1.23.1.3
NuGet\Install-Package go.runtime.pprof -Version 1.23.1.3
<PackageReference Include="go.runtime.pprof" Version="1.23.1.3" />
<PackageVersion Include="go.runtime.pprof" Version="1.23.1.3" />
<PackageReference Include="go.runtime.pprof" />
paket add go.runtime.pprof --version 1.23.1.3
#r "nuget: go.runtime.pprof, 1.23.1.3"
#:package go.runtime.pprof@1.23.1.3
#addin nuget:?package=go.runtime.pprof&version=1.23.1.3
#tool nuget:?package=go.runtime.pprof&version=1.23.1.3
go.runtime.pprof
C# package converted from the Go standard library by go2cs. Go version: 1.23.1
Package pprof writes runtime profiling data in the format expected by the pprof visualization tool.
Profiling a Go program
The first step to profiling a Go program is to enable profiling. Support for profiling benchmarks built with the standard testing package is built into go test. For example, the following command runs benchmarks in the current directory and writes the CPU and memory profiles to cpu.prof and mem.prof:
go test -cpuprofile cpu.prof -memprofile mem.prof -bench .
To add equivalent profiling support to a standalone program, add code like the following to your main function:
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`")
var memprofile = flag.String("memprofile", "", "write memory profile to `file`")
func main() {
flag.Parse()
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal("could not create CPU profile: ", err)
}
defer f.Close() // error handling omitted for example
if err := pprof.StartCPUProfile(f); err != nil {
log.Fatal("could not start CPU profile: ", err)
}
defer pprof.StopCPUProfile()
}
// ... rest of the program ...
if *memprofile != "" {
f, err := os.Create(*memprofile)
if err != nil {
log.Fatal("could not create memory profile: ", err)
}
defer f.Close() // error handling omitted for example
runtime.GC() // get up-to-date statistics
if err := pprof.WriteHeapProfile(f); err != nil {
log.Fatal("could not write memory profile: ", err)
}
}
}
There is also a standard HTTP interface to profiling data. Adding the following line will install handlers under the /debug/pprof/ URL to download live profiles:
import _ "net/http/pprof"
See the net/http/pprof package for more details.
Profiles can then be visualized with the pprof tool:
go tool pprof cpu.prof
There are many commands available from the pprof command line. Commonly used commands include "top", which prints a summary of the top program hot-spots, and "web", which opens an interactive graph of hot-spots and their call graphs. Use "help" for information on all pprof commands.
For more information about pprof, see https://github.com/google/pprof/blob/main/doc/README.md.
Part of the go2cs converted Go standard library. See the repository for usage and details.
Copyright 2009 The Go Authors. All rights reserved. This C# package is converted from Go standard library source; use of that source is governed by a BSD-style license that can be found in the LICENSE file. The go2cs conversion itself is distributed under the MIT license.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- go.bufio (>= 1.23.1.3)
- go.bytes (>= 1.23.1.3)
- go.cmp (>= 1.23.1.3)
- go.compress.gzip (>= 1.23.1.3)
- go.context (>= 1.23.1.3)
- go.encoding.binary (>= 1.23.1.3)
- go.errors (>= 1.23.1.3)
- go.fmt (>= 1.23.1.3)
- go.internal.abi (>= 1.23.1.3)
- go.internal.profilerecord (>= 1.23.1.3)
- go.internal.syscall.windows (>= 1.23.1.3)
- go.io (>= 1.23.1.3)
- go.lib (>= 1.23.1.3)
- go.math (>= 1.23.1.3)
- go.os (>= 1.23.1.3)
- go.runtime (>= 1.23.1.3)
- go.slices (>= 1.23.1.3)
- go.sort (>= 1.23.1.3)
- go.strconv (>= 1.23.1.3)
- go.strings (>= 1.23.1.3)
- go.sync (>= 1.23.1.3)
- go.syscall (>= 1.23.1.3)
- go.text.tabwriter (>= 1.23.1.3)
- go.time (>= 1.23.1.3)
- go.unsafe (>= 1.23.1.3)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on go.runtime.pprof:
| Package | Downloads |
|---|---|
|
go.net.http.pprof
net.http.pprof (net9.0 - Release) -- C# project converted from Go source |
|
|
go.testing.internal.testdeps
testing.internal.testdeps (net9.0 - Release) -- C# project converted from Go source |
GitHub repositories
This package is not used by any popular GitHub repositories.