• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang profile.Start函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/pkg/profile.Start函数的典型用法代码示例。如果您正苦于以下问题:Golang Start函数的具体用法?Golang Start怎么用?Golang Start使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Start函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:Yelp,项目名称:fullerite,代码行数:34,代码来源:main.go


示例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()
}
开发者ID:balamurugana,项目名称:mc,代码行数:30,代码来源:main.go


示例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
}
开发者ID:logv,项目名称:sybil,代码行数:8,代码来源:enable_profiler.go


示例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())
}
开发者ID:brettlangdon,项目名称:realm,代码行数:51,代码来源:main.go


示例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
}
开发者ID:RomainVabre,项目名称:origin,代码行数:14,代码来源:serviceability.go


示例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
	}

}
开发者ID:tixu,项目名称:mmjira,代码行数:14,代码来源:utils.go


示例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
	}
}
开发者ID:krishnasrinivas,项目名称:minio,代码行数:16,代码来源:utils.go


示例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
	}
}
开发者ID:RomainVabre,项目名称:origin,代码行数:15,代码来源:example_test.go


示例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
}
开发者ID:getcfs,项目名称:cfs-binary-release,代码行数:31,代码来源:main.go


示例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()
}
开发者ID:hjfreyer,项目名称:misc,代码行数:25,代码来源:hearth.go


示例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()
}
开发者ID:FPurchess,项目名称:blank,代码行数:28,代码来源:advanced_single_binary_distribution.go


示例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()
}
开发者ID:technopoetic,项目名称:go_search,代码行数:8,代码来源:main.go


示例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")
		}
	})
}
开发者ID:smancke,项目名称:guble,代码行数:47,代码来源:gubled.go


示例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
	}
}
开发者ID:hackintoshrao,项目名称:minio,代码行数:18,代码来源:utils.go


示例15: main

func main() {
	p := profile.Start(
		profile.MemProfile,
		profile.ProfilePath("."))
	defer p.Stop()

	q := queue.NewDeque()
	fill(q)
	clear(q)
}
开发者ID:FSX,项目名称:exercises,代码行数:10,代码来源:deque_profile.go


示例16: main

func main() {
	//prof := profile.CPUProfile
	prof := profile.MemProfile
	defer profile.Start(prof, profile.ProfilePath(".")).Stop()

	t := bpt.NewTree()
	for i := 0; i < 1000000; i++ {
		x := []byte(fmt.Sprintf("%x", i))
		t.Set(x, x)
	}
	t.Close()
}
开发者ID:cagnosolutions,项目名称:bpt,代码行数:12,代码来源:prof.go


示例17: main

func main() {
	prof := profile.CPUProfile
	//prof := profile.MemProfile
	defer profile.Start(prof, profile.ProfilePath(".")).Stop()

	t := bptx.NewTree()
	for i := 0; i < 10000; i++ {
		x := bptx.UUID()
		t.Set(x, x)
	}
	t.Close()
}
开发者ID:cagnosolutions,项目名称:bpt,代码行数:12,代码来源:prof.go


示例18: main

func main() {
	flag.Parse()

	input := flag.Arg(0)
	output := flag.Arg(1)
	cwd, _ := os.Getwd()
	defer profile.Start(profile.ProfilePath(cwd)).Stop()

	m, _ := mapping.NewMap(input)

	r := rendering.NewRenderer(m, 5000, 5000)

	r.ClipToMap()
	r.DrawToFile(output)
}
开发者ID:samlecuyer,项目名称:ecumene,代码行数:15,代码来源:main.go


示例19: main

func main() {
	p := profile.Start(
		profile.MemProfile,
		profile.ProfilePath("."),
		profile.NoShutdownHook)
	defer p.Stop()

	u := &command.Unit{"Test-01", 0, 0}
	s := command.NewCommandStack(10)
	s.Do(command.NewMoveUnitCommand(u, 10, 10))

	for i := 0; i < 10000000; i++ {
		s.Do(command.NewMoveUnitCommand(u, i*10, i*10))
	}
}
开发者ID:FSX,项目名称:exercises,代码行数:15,代码来源:command_profile.go


示例20: main

func main() {
	config.InitConfig()

	if config.EnableProfile {
		defer profile.Start(profile.CPUProfile).Stop()
	}

	runtime.GOMAXPROCS(runtime.NumCPU() * 3)
	utils.InitLogger()
	if config.RC.MySQLEnabled {
		query.RC_MySQLConf = config.RC.MySQLConf
		query.InitMySQL(query.RC_MySQLConf)
	}
	server.NewServer()

}
开发者ID:chunshengster,项目名称:httpDispatcher,代码行数:16,代码来源:main.go



注:本文中的github.com/pkg/profile.Start函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang sftp.Close函数代码示例发布时间:2022-05-28
下一篇:
Golang errors.Wrapf函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap