当前位置: 首页>>代码示例>>Golang>>正文


Golang profile.Start函数代码示例

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


在下文中一共展示了Start函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	defer profile.Start(&profile.Config{CPUProfile: true, ProfilePath: "/tmp/"}).Stop()

	//	nCPU := runtime.NumCPU()
	nCPU := 2
	runtime.GOMAXPROCS(nCPU)
	log.Printf("running on %d CPUs", nCPU)

	server := network.NewServer("8081")
	server.Start()

	world = NewWorld(entityManager, server)

	go world.worldTick()
	go world.networkTick()

	// wait for signal
	signalChan := make(chan os.Signal, 1)
	cleanupDone := make(chan bool)
	signal.Notify(signalChan, os.Interrupt)
	go func() {
		for _ = range signalChan {
			log.Printf("Received an interrupt, stopping services...\n")
			server.Stop()
			cleanupDone <- true
		}
	}()
	<-cleanupDone
}
开发者ID:stojg,项目名称:pants,代码行数:29,代码来源:main.go

示例2: main

func main() {
	password := flag.String("password", "", "Password for all redis instances")
	db := flag.Int("db", 0, "DB number")
	socket := flag.String("socket", "/tmp/redis-monitor.sock", "Socket to provide metrics over")
	flag.Parse()
	if len(flag.Args()) < 1 {
		flag.Usage()
		os.Exit(1)
	}
	s := &http.Server{
		Handler: &Addresses{
			Addr:     flag.Args(),
			Password: *password,
			DB:       int64(*db),
		},
	}

	l, err := util.CreateSocket(*socket)

	go func() {
		log.Println(http.ListenAndServe("localhost:6060", nil))
	}()

	defer profile.Start(profile.MemProfile).Stop()

	if err != nil {
		panic(err)
	}

	if err := s.Serve(l); err != nil {
		panic(err)
	}
}
开发者ID:mehulsbhatt,项目名称:gollector-monitors,代码行数:33,代码来源:redis-monitor.go

示例3: start

func start(ctx *cli.Context) {
	if ctx.Bool("profile") {
		pcfg := profile.Config{
			CPUProfile:   true,
			MemProfile:   true,
			BlockProfile: true,
			ProfilePath:  ".",
		}
		p := profile.Start(&pcfg)
		defer p.Stop()
	}
	initLogrus(ctx)
	log.Info("Starting fullerite...")

	c, err := config.ReadConfig(ctx.String("config"))
	if err != nil {
		return
	}
	collectors := startCollectors(c)
	handlers := startHandlers(c)
	metrics := make(chan metric.Metric)
	readFromCollectors(collectors, metrics)
	for metric := range metrics {
		// Writing to handlers' channels. Sending metrics is
		// handled asynchronously in handlers' Run functions.
		writeToHandlers(handlers, metric)
	}
}
开发者ID:jaxxstorm,项目名称:fullerite,代码行数:28,代码来源:main.go

示例4: main

func main() {
	cfg := profile.Config{
		MemProfile:     true,
		CPUProfile:     true,
		BlockProfile:   true,
		ProfilePath:    ".",
		NoShutdownHook: true,
	}

	defer profile.Start(&cfg).Stop()
	c := make(chan int)
	go func() {
		//http.ListenAndServe("0.0.0.0:6060", nil)
	}()
	//<-c
	for i := 0; i < 1000; i++ {
		go func(i int) {
			//fmt.Println(test())
			test()
			c <- i
		}(i)
	}
	//<-c //for http
	for i := 0; i < 1000; i++ {
		<-c
	}

	//println(http.ListenAndServe("localhost:6062", nil))
}
开发者ID:RustJason,项目名称:LearningNote,代码行数:29,代码来源:prof.go

示例5: main

func main() {
	defer profile.Start(profile.CPUProfile).Stop()
	flag.Parse()
	dm := docmap.NewDocMap()
	err := dm.DocReader()

	if err != nil {
		println(err)
		return
	}
	qm := querrymap.NewQuerryMap()

	qm.QuerryReader()

	im := invertmap.NewInvertMap()

	err = im.DocMToInM(dm)

	if err != nil {
		println(err)
	}

	if *startQuerry {
		qproc.QuerriesProc(dm, qm, im)
	} else {
		println("No webservice")
	}

}
开发者ID:zaker,项目名称:Search_engine,代码行数:29,代码来源:main.go

示例6: main

func main() {
	// Set up a done channel, that's shared by the whole pipeline.
	// Closing this channel will kill all pipeline goroutines
	//done := make(chan struct{})
	//defer close(done)

	// Set up logging
	initializeLogging()

	// Flush the log before we shutdown
	defer log.Flush()

	// Parse the command line flags
	config := parseCommandLineFlags()
	gamq.SetConfig(&config)

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

	log.Infof("Broker started on port: %d", gamq.Configuration.Port)
	log.Infof("Executing on: %d threads", runtime.GOMAXPROCS(-1))

	connectionManager := gamq.NewConnectionManager()
	connectionManager.Start()
}
开发者ID:FireEater64,项目名称:gamq,代码行数:26,代码来源:gamq.go

示例7: TestPerft

func TestPerft(t *testing.T) {
	t.SkipNow()
	cfg := profile.Config{
		CPUProfile:     false,
		MemProfile:     false,
		ProfilePath:    ".",  // store profiles in current directory
		NoShutdownHook: true, // do not hook SIGINT
	}
	p := profile.Start(&cfg)
	//t.SkipNow()
	loadPerft(t)

	for _, depth := range depths {
		setupBoard()
		res := perft(depth, t, g)
		excepted := sharperPerftLookup(depth, t)
		if res == excepted {
			t.Log("okPerft("+strconv.Itoa(depth)+") Result:", res, " Expected:", excepted)
		} else {
			t.Log("X Perft("+strconv.Itoa(depth)+") Result:", res, " Expected:", excepted)
			t.Fail()
		}
	}
	p.Stop()
}
开发者ID:JyBP,项目名称:ws-chess,代码行数:25,代码来源:perft_test.go

示例8: start

func start(ctx *cli.Context) {
	if ctx.Bool("profile") {
		pcfg := profile.Config{
			CPUProfile:   true,
			MemProfile:   true,
			BlockProfile: true,
			ProfilePath:  ".",
		}
		p := profile.Start(&pcfg)
		defer p.Stop()
	}
	initLogrus(ctx)
	log.Info("Starting fullerite...")

	c, err := config.ReadConfig(ctx.String("config"))
	if err != nil {
		return
	}
	collectors := startCollectors(c)
	handlers := startHandlers(c)

	internalServer := internalserver.New(c, &handlers)
	go internalServer.Run()

	metrics := make(chan metric.Metric)
	readFromCollectors(collectors, metrics)

	hook := NewLogErrorHook(metrics)
	log.Logger.Hooks.Add(hook)

	relayMetricsToHandlers(handlers, metrics)
}
开发者ID:carriercomm,项目名称:fullerite,代码行数:32,代码来源:main.go

示例9: main

func main() {
	port := flag.Int("port", 8080, "port")
	backends := flag.Int("workers", 3, "number of workers")
	strategy := flag.String("strategy", "majority", "balancing strategy ['one', 'two', 'majority', 'all']")
	flag.Parse()

	cfg := profile.Config{
		CPUProfile:  true,
		MemProfile:  true,
		ProfilePath: ".",
	}
	p := profile.Start(&cfg)
	defer p.Stop()

	balancer := newBalancer(backends, strategy)

	a := gin.Default()
	a.GET("/", func(c *gin.Context) {
		timeouted := make(chan bool)
		result := processFirstResponse(timeouted, balancer)

		select {
		case data := <-result:
			c.JSON(200, data)
		case <-time.After(globalTimeout):
			c.JSON(500, nil)
			timeouted <- true
		}

	})
	a.Run(fmt.Sprintf(":%d", *port))

}
开发者ID:alombarte,项目名称:gokatas,代码行数:33,代码来源:main.go

示例10: main

func main() {

	/* # # # # #  ENABLING PROFILING # # # # # */
	defer profile.Start(profile.CPUProfile).Stop()
	/*
		profileConfig := profile.Config{
			CPUProfile:     true,
			MemProfile:     true,
			ProfilePath:    ".",  // store profiles in current directory
			NoShutdownHook: true, // do not hook SIGINT
		}
		p := profile.Start(&profileConfig)
		defer p.Stop()
	*/
	/* # # # # #  ENABLING PROFILING # # # # # */

	ts.Cache("index.html", "home.html", "404.html")

	mux := MuxInstance()
	mux.Handle("GET", "/index", index)
	mux.Handle("GET", "/home", home)
	mux.Handle("GET", "/404", err404)
	mux.Handle("GET", "/user", user)
	mux.Handle("GET", "/user/add", userAdd)
	mux.Handle("GET", "/user/:id", userId)
	mux.Handle("GET", "/:slug", landing)
	mux.Handle("GET", "/login/:slug", multiLogin)
	mux.Handle("GET", "/logout/:slug", logout)
	mux.Handle("GET", "/protected/:slug", protected)

	http.ListenAndServe(":8080", mux)
}
开发者ID:gregpechiro,项目名称:web,代码行数:32,代码来源:main.go

示例11: main

func main() {
	address := flag.String("s", "127.0.0.1", "Bind Address")
	port := flag.String("p", "11211", "Bind Port")
	filename := flag.String("f", "./memcached.db", "path and file for database")
	pf := flag.Bool("q", false, "Enable profiling")

	flag.Usage = func() {
		fmt.Println("Usage: beano [-s ip] [-p port] [-f /path/to/db/file -q]")
		fmt.Println("default ip: 127.0.0.1")
		fmt.Println("default port: 11211")
		fmt.Println("default file: ./memcached.db")
		fmt.Println("-q enables profiling to /tmp/*.prof")
		os.Exit(1)
	}
	flag.Parse()
	if *pf == true {
		c := profile.Config{BlockProfile: true, CPUProfile: true, ProfilePath: "/tmp", MemProfile: true, Quiet: false}
		defer profile.Start(&c).Stop()
	}
	var cpuinfo string
	if n := runtime.NumCPU(); n > 1 {
		runtime.GOMAXPROCS(n)
		cpuinfo = fmt.Sprintf("%d CPUs", n)
	} else {
		cpuinfo = "1 CPU"
	}

	log.Info("beano (%s)", cpuinfo)

	initializeMetrics(*filename)

	serve(*address, *port, *filename)

}
开发者ID:shitfSign,项目名称:beano,代码行数:34,代码来源:main.go

示例12: main

func main() {

	fmt.Println("Server Starting on port:8080")
	defer profile.Start(profile.CPUProfile).Stop()
	pc := controller.NewProjectController(getDbSession())
	uc := controller.NewUserController(getDbSession())
	sc := controller.NewSensorController(getDbSession())
	vc := controller.NewVirtSensorController(getDbSession())

	router := httprouter.New()

	//Project Management Routings
	router.Handle("GET", "/projects", pc.Project)
	router.Handle("POST", "/addproject", pc.AddProject)
	router.Handle("GET", "/projects/:projectName/selectsensors", pc.SelectSensors)
	router.Handle("POST", "/projects/:projectName/addvirtualsensors", pc.AddSensorToProject)
	router.Handle("GET", "/projects/:projectName/dashboard", pc.Dashboard)
	router.Handle("GET", "/projects/:projectName/terminate", pc.TerminateProject)
	/*router.Handle("GET", "/sendvirtualsensordetails/", handle)
	router.Handle("POST", "/projects/:projectName/addvirtualsensors", handle)
	router.Handle("GET", "/projects/:projectName/startvirtsensor/:vsensorid", handle)
	router.Handle("GET", "/projects/:projectName/stopvirtsensor/:vsensorid", handle)
	router.Handle("GET", "/projects/:projectName/terminatevirtsensor/:vsensorid", handle)*/

	// User Management Routings
	router.Handle("GET", "/", uc.Index)
	router.Handle("GET", "/logout", uc.Logout)
	router.Handle("POST", "/users/login", uc.Login)
	router.Handle("POST", "/users/signup", uc.Signup)
	router.Handle("PUT", "/users/updateuser/:username", uc.UpdateUser)
	router.Handle("DELETE", "/users/deleteuser/:username", uc.DeleteUser)
	router.Handle("GET", "/time", uc.Datahandler)
	router.Handle("GET", "/gettime", uc.HandlerGetData)

	//Physical Sensor Management Routings
	router.Handle("POST", "/sensors", sc.AddSensor)
	router.Handle("PUT", "/sensors/updatesensor/:sensorName", sc.UpdateSensor)
	router.Handle("DELETE", "/sensors/deletesensor/:sensorName", sc.DeleteSensor)
	router.Handle("GET", "/sensors/getsensor/:sensorName", sc.GetSensorByName)
	router.Handle("POST", "/authenticatesenor", sc.AuthenticateSensor)
	router.Handle("GET", "/getsensorbyowner/:ownerId", sc.GetSensorByOwner)
	router.Handle("GET", "/getallsharedsensors", sc.GetAllSharedSensors)
	//router.Handle("POST", "/getsensordata",sc.GetSensorData)
	//router.Handle("PUT", "/sensors/togglesensor/:sensorName", ToggelSensor)
	/*router.Handle("GET", "/getsensorbyowner/:ownerId", GetSensorById)*/

	// Virtual Sensor Management Routings
	router.Handle("POST", "/virtsensors", vc.AddVirtSensor)
	router.Handle("PUT", "/removevirtsensors/:vSensorName", vc.RemoveVirtSensor)
	router.Handle("GET", "/stopvirtsensors/:vSensorName", vc.StopVirtSensor)
	router.Handle("GET", "/resumevirtsensors/:vSensorName", vc.ResumeVirtSensor)
	router.Handle(("GET"), "/projects/:projectName/sensors/:vSensorName", vc.GetVSensorDetails)

	//fileServer := http.StripPrefix("/static/", http.FileServer(http.Dir("static")))
	router.NotFound = http.StripPrefix("/static/", http.FileServer(http.Dir("static")))
	log.Fatal(http.ListenAndServe(":8081", router))
}
开发者ID:Jessianngeorge,项目名称:MobileSensorCloudEngine,代码行数:57,代码来源:server1.go

示例13: main

func main() {
	profileKind := os.Args[1]
	switch profileKind {
	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:
		fmt.Println("only cpu, mem and block are valid profile arguments")
		return
	}

	for i := 0; i < 1000000; i++ {
		user := &User{
			Name: "Emil Sjölander",
			Repos: []Repo{
				Repo{
					Name:  "goson",
					URL:   "https://github.com/emilsjolander/goson",
					Stars: 0,
					Forks: 0,
				},
				Repo{
					Name:  "StickyListHeaders",
					URL:   "https://github.com/emilsjolander/StickyListHeaders",
					Stars: 722,
					Forks: 197,
				},
				Repo{
					Name:  "android-FlipView",
					URL:   "https://github.com/emilsjolander/android-FlipView",
					Stars: 157,
					Forks: 47,
				},
			},
		}

		goson.Render("user", goson.Args{"User": user})
	}
}
开发者ID:hooblei,项目名称:goson,代码行数:42,代码来源:profile.go

示例14: main

func main() {
	defer profile.Start(profile.CPUProfile).Stop()

	flag.Parse()
	for _, path := range flag.Args() {
		err := flac2wav(path)
		if err != nil {
			log.Fatalln(err)
		}
	}
}
开发者ID:mewmew,项目名称:playground,代码行数:11,代码来源:flac2wav.go

示例15: initProfiler

func initProfiler() {
	cfg := profile.Config{
		MemProfile:  true,
		CPUProfile:  true,
		ProfilePath: ".", // store profiles in current directory
	}

	// p.Stop() must be called before the program exits to
	// ensure profiling information is written to disk.
	profiler = profile.Start(&cfg)
}
开发者ID:unitrans,项目名称:unitrans,代码行数:11,代码来源:main.go


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