本文整理汇总了Golang中github.com/pkg/profile.Start函数的典型用法代码示例。如果您正苦于以下问题:Golang Start函数的具体用法?Golang Start怎么用?Golang Start使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Start函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: start
func start(ctx *cli.Context) {
if ctx.Bool("profile") {
defer profile.Start(profile.CPUProfile).Stop()
defer profile.Start(profile.MemProfile).Stop()
defer profile.Start(profile.BlockProfile).Stop()
defer profile.Start(profile.ProfilePath("."))
}
quit := make(chan bool)
initLogrus(ctx)
log.Info("Starting fullerite...")
c, err := config.ReadConfig(ctx.String("config"))
if err != nil {
return
}
handlers := createHandlers(c)
hook := NewLogErrorHook(handlers)
log.Logger.Hooks.Add(hook)
startHandlers(handlers)
collectors := startCollectors(c)
collectorStatChan := make(chan metric.CollectorEmission)
internalServer := internalserver.New(c,
handlerStatFunc(handlers),
readCollectorStat(collectorStatChan))
go internalServer.Run()
readFromCollectors(collectors, handlers, collectorStatChan)
<-quit
}
示例2: Main
// Main starts mc application
func Main() {
// Enable profiling supported modes are [cpu, mem, block].
// ``MC_PROFILER`` supported options are [cpu, mem, block].
switch os.Getenv("MC_PROFILER") {
case "cpu":
defer profile.Start(profile.CPUProfile, profile.ProfilePath(mustGetProfileDir())).Stop()
case "mem":
defer profile.Start(profile.MemProfile, profile.ProfilePath(mustGetProfileDir())).Stop()
case "block":
defer profile.Start(profile.BlockProfile, profile.ProfilePath(mustGetProfileDir())).Stop()
}
probe.Init() // Set project's root source path.
probe.SetAppInfo("Release-Tag", ReleaseTag)
probe.SetAppInfo("Commit", ShortCommitID)
app := registerApp()
app.Before = registerBefore
app.ExtraInfo = func() map[string]string {
if _, e := pb.GetTerminalWidth(); e != nil {
globalQuiet = true
}
if globalDebug {
return getSystemData()
}
return make(map[string]string)
}
app.RunAndExitOnError()
}
示例3: Start
func (p PkgProfile) Start() ProfilerStart {
if *FLAGS.PROFILE_MEM {
PROFILE = profile.Start(profile.MemProfile, profile.ProfilePath("."))
} else {
PROFILE = profile.Start(profile.CPUProfile, profile.ProfilePath("."))
}
return PROFILE
}
示例4: main
func main() {
args.Bind = ":53"
argParser := arg.MustParse(&args)
// Enable profiling
switch args.Profile {
case "cpu":
defer profile.Start(profile.CPUProfile).Stop()
case "mem":
defer profile.Start(profile.MemProfile).Stop()
case "block":
defer profile.Start(profile.BlockProfile).Stop()
}
// Control number of workers via GOMAXPROCS
if args.Workers > 0 {
runtime.GOMAXPROCS(args.Workers)
}
if len(args.Zones) == 0 {
log.Println("must supply at least 1 zone file to serve")
argParser.WriteUsage(os.Stderr)
os.Exit(1)
}
var registry *realm.Registry
registry = realm.NewRegistry()
for _, filename := range args.Zones {
// Load and parse the zone file
var zone *realm.Zone
var err error
log.Printf("parsing zone file \"%s\"\n", filename)
zone, err = realm.ParseZone(filename)
if err != nil {
log.Fatal(err)
}
registry.AddZone(zone)
}
// Create and start the server
log.Printf("starting the server on \"%s\"\n", args.Bind)
var server *realm.Server
var err error
server, err = realm.NewServer(args.Bind, registry, args.StatsD)
if err != nil {
log.Fatal(err)
}
log.Fatal(server.ListenAndServe())
}
示例5: Profile
func Profile(mode string) Stop {
var stop Stop
switch mode {
case "mem":
stop = profileOnExit(profile.Start(profile.MemProfile, profile.ProfilePath("."), profile.NoShutdownHook))
case "cpu":
stop = profileOnExit(profile.Start(profile.CPUProfile, profile.ProfilePath("."), profile.NoShutdownHook))
case "block":
stop = profileOnExit(profile.Start(profile.BlockProfile, profile.ProfilePath("."), profile.NoShutdownHook))
default:
stop = stopper{}
}
return stop
}
示例6: activateProfiline
func activateProfiline(profileType string, dir string) {
// activating
switch profileType {
case "cpu":
defer profile.Start(profile.ProfilePath(dir), profile.CPUProfile).Stop()
case "mem":
defer profile.Start(profile.ProfilePath(dir), profile.MemProfile).Stop()
case "block":
defer profile.Start(profile.ProfilePath(dir), profile.BlockProfile).Stop()
default:
// do nothing
}
}
示例7: startProfiler
// Starts a profiler returns nil if profiler is not enabled, caller needs to handle this.
func startProfiler(profiler string) interface {
Stop()
} {
// Enable profiler if ``_MINIO_PROFILER`` is set. Supported options are [cpu, mem, block].
switch profiler {
case "cpu":
return profile.Start(profile.CPUProfile, profile.NoShutdownHook)
case "mem":
return profile.Start(profile.MemProfile, profile.NoShutdownHook)
case "block":
return profile.Start(profile.BlockProfile, profile.NoShutdownHook)
default:
return nil
}
}
示例8: ExampleStart_withFlags
func ExampleStart_withFlags() {
// use the flags package to selectively enable profiling.
mode := flag.String("profile.mode", "", "enable profiling mode, one of [cpu, mem, block]")
flag.Parse()
switch *mode {
case "cpu":
defer profile.Start(profile.CPUProfile).Stop()
case "mem":
defer profile.Start(profile.MemProfile).Stop()
case "block":
defer profile.Start(profile.BlockProfile).Stop()
default:
// do nothing
}
}
示例9: main
func main() {
flag.Parse()
if *clients > *num {
log.Println("# of clients can't be greater than # of keys written")
return
}
runtime.GOMAXPROCS(*procs)
if *profileEnable {
defer profile.Start().Stop()
}
s := NewScrambled()
value = make([]byte, *vsize)
s.Read(value)
perClient = *num / *clients
perGroup := perClient / *groups
if perGroup == 0 {
log.Printf("Can't split %d writes across %d groups", perClient, *groups)
log.Println("Need -num to be at least:", *clients**groups)
return
}
log.Println("Using streaming api:", *streamTest)
if *vsWriteTest || *vsReadTest {
VSTests()
}
if *gsWriteTest || *gsReadTest {
GSTests()
}
return
}
示例10: main
func main() {
r := rand.New(rand.NewSource(4))
players := make([]*player, numPlayers)
m := make(map[int]map[*player]bool)
m[0] = make(map[*player]bool)
for i := range players {
players[i] = &player{
skill: r.NormFloat64() * skillStdDev,
}
m[0][players[i]] = true
}
a := arena{
r: r,
allPlayers: players,
playersByStars: m,
}
defer profile.Start().Stop()
for i := 0; i < numPlayers*avgNumGamesPerPlayer; i++ {
a.fight()
}
a.print()
}
示例11: main
func main() {
thrust.InitLogger()
// Set any Custom Provisioners before Start
thrust.SetProvisioner(provisioner.NewSingleBinaryThrustProvisioner())
// thrust.Start() must always come before any bindings are created.
thrust.Start()
thrustWindow := thrust.NewWindow(thrust.WindowOptions{
RootUrl: "http://breach.cc/",
HasFrame: true,
})
thrustWindow.Show()
thrustWindow.Focus()
// Lets do a window timeout
go func() {
// <-time.After(time.Second * 5)
// thrustWindow.Close()
// thrust.Exit()
}()
// In lieu of something like an http server, we need to lock this thread
// in order to keep it open, and keep the process running.
// Dont worry we use runtime.Gosched :)
defer profile.Start().Stop()
thrust.LockThread()
}
示例12: main
func main() {
p := profile.Start(profile.MemProfile, profile.ProfilePath("."), profile.NoShutdownHook)
// initialize representation
index, _ = iindex.IndexDirectory("/home/rhibbitts/Dropbox/Notes/WorkNotes")
// run user interface
ui()
p.Stop()
}
示例13: Main
// Main is the entry-point of the guble server.
func Main() {
defer func() {
if p := recover(); p != nil {
logger.Fatal("Fatal error in gubled after recover")
}
}()
parseConfig()
log.SetFormatter(&logformatter.LogstashFormatter{Env: *Config.EnvName})
level, err := log.ParseLevel(*Config.Log)
if err != nil {
logger.WithError(err).Fatal("Invalid log level")
}
log.SetLevel(level)
switch *Config.Profile {
case cpuProfile:
logger.Info("starting to profile cpu")
defer profile.Start(profile.CPUProfile).Stop()
case memProfile:
logger.Info("starting to profile memory")
defer profile.Start(profile.MemProfile).Stop()
case blockProfile:
logger.Info("starting to profile blocking/contention")
defer profile.Start(profile.BlockProfile).Stop()
default:
logger.Debug("no profiling was started")
}
if err := ValidateStoragePath(); err != nil {
logger.Fatal("Fatal error in gubled in validation of storage path")
}
srv := StartService()
if srv == nil {
logger.Fatal("exiting because of unrecoverable error(s) when starting the service")
}
waitForTermination(func() {
err := srv.Stop()
if err != nil {
logger.WithField("error", err.Error()).Error("errors occurred while stopping service")
}
})
}
示例14: startProfiler
// Starts a profiler returns nil if profiler is not enabled, caller needs to handle this.
func startProfiler(profiler string) interface {
Stop()
} {
// Set ``MINIO_PROFILE_DIR`` to the directory where profiling information should be persisted
profileDir := os.Getenv("MINIO_PROFILE_DIR")
// Enable profiler if ``MINIO_PROFILER`` is set. Supported options are [cpu, mem, block].
switch profiler {
case "cpu":
return profile.Start(profile.CPUProfile, profile.NoShutdownHook, profile.ProfilePath(profileDir))
case "mem":
return profile.Start(profile.MemProfile, profile.NoShutdownHook, profile.ProfilePath(profileDir))
case "block":
return profile.Start(profile.BlockProfile, profile.NoShutdownHook, profile.ProfilePath(profileDir))
default:
return nil
}
}
示例15: main
func main() {
p := profile.Start(
profile.MemProfile,
profile.ProfilePath("."))
defer p.Stop()
q := queue.NewDeque()
fill(q)
clear(q)
}