mirror of
https://github.com/restic/restic.git
synced 2025-12-08 06:09:56 +00:00
Vendor dependencies with dep
This commit is contained in:
parent
df8a5792f1
commit
91edebf1fe
1691 changed files with 466360 additions and 0 deletions
58
vendor/github.com/pkg/profile/example_test.go
generated
vendored
Normal file
58
vendor/github.com/pkg/profile/example_test.go
generated
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package profile_test
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
|
||||
"github.com/pkg/profile"
|
||||
)
|
||||
|
||||
func ExampleStart() {
|
||||
// start a simple CPU profile and register
|
||||
// a defer to Stop (flush) the profiling data.
|
||||
defer profile.Start().Stop()
|
||||
}
|
||||
|
||||
func ExampleCPUProfile() {
|
||||
// CPU profiling is the default profiling mode, but you can specify it
|
||||
// explicitly for completeness.
|
||||
defer profile.Start(profile.CPUProfile).Stop()
|
||||
}
|
||||
|
||||
func ExampleMemProfile() {
|
||||
// use memory profiling, rather than the default cpu profiling.
|
||||
defer profile.Start(profile.MemProfile).Stop()
|
||||
}
|
||||
|
||||
func ExampleMemProfileRate() {
|
||||
// use memory profiling with custom rate.
|
||||
defer profile.Start(profile.MemProfileRate(2048)).Stop()
|
||||
}
|
||||
|
||||
func ExampleProfilePath() {
|
||||
// set the location that the profile will be written to
|
||||
defer profile.Start(profile.ProfilePath(os.Getenv("HOME"))).Stop()
|
||||
}
|
||||
|
||||
func ExampleNoShutdownHook() {
|
||||
// disable the automatic shutdown hook.
|
||||
defer profile.Start(profile.NoShutdownHook).Stop()
|
||||
}
|
||||
|
||||
func ExampleStart_withFlags() {
|
||||
// use the flags package to selectively enable profiling.
|
||||
mode := flag.String("profile.mode", "", "enable profiling mode, one of [cpu, mem, mutex, block]")
|
||||
flag.Parse()
|
||||
switch *mode {
|
||||
case "cpu":
|
||||
defer profile.Start(profile.CPUProfile).Stop()
|
||||
case "mem":
|
||||
defer profile.Start(profile.MemProfile).Stop()
|
||||
case "mutex":
|
||||
defer profile.Start(profile.MutexProfile).Stop()
|
||||
case "block":
|
||||
defer profile.Start(profile.BlockProfile).Stop()
|
||||
default:
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue