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


Golang trace.Start函数代码示例

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


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

示例1: main

func main() {
	trace.Start(os.Stderr)
	http.HandleFunc("/", handler)
	go http.ListenAndServe(":5000", nil)
	time.Sleep(100 * time.Millisecond)
	trace.Stop()
}
开发者ID:divan,项目名称:talks,代码行数:7,代码来源:causal_orig2.go

示例2: main

func main() {
	trace.Start(os.Stderr)
	ch, ch1 := make(chan int), make(chan int)
	out := make(chan int)
	go func() {
		for i := 0; i < 20; i++ {
			v := <-out
			fmt.Println("Recv ", v)
			time.Sleep(100 * time.Microsecond)
		}
	}()
	go func() {
		for i := 0; i < 10; i++ {
			ch <- i
		}
	}()
	go func() {
		for i := 0; i < 10; i++ {
			ch <- i
		}
	}()

	for i := 0; i < 20; i++ {
		select {
		case v := <-ch:
			out <- v
		case v := <-ch1:
			out <- v
		}
	}
	trace.Stop()
}
开发者ID:yujinqiu,项目名称:gotrace,代码行数:32,代码来源:select2.go

示例3: main

func main() {
	trace.Start(os.Stderr)
	for i := 0; i < 1000; i++ {
		go leaker()
	}
	trace.Stop()
}
开发者ID:divan,项目名称:talks,代码行数:7,代码来源:leak.go

示例4: main

func main() {

	f, err := os.Create("trace")
	if err != nil {
		panic(err)
	}
	defer func() {
		if err := f.Close(); err != nil {
			panic(err)
		}
	}()

	trace.Start(f)

	for i := 0; i < 10; i++ {
		go bob(i)
	}

	time.Sleep(time.Duration(20) * time.Second)
	fmt.Println("writing trace")

	trace.Stop()

	time.Sleep(time.Duration(100) * time.Second)
}
开发者ID:deferpanic,项目名称:tracelib,代码行数:25,代码来源:main.go

示例5: startWritingTrace

func startWritingTrace(profilesDir string) error {
	traceFile, err := os.Create(filepath.Join(profilesDir, "trace"))
	if err != nil {
		return err
	}
	return trace.Start(traceFile)
}
开发者ID:gkalabin,项目名称:goprof,代码行数:7,代码来源:hooks.go

示例6: main

func main(f func(*App)) {
	flag.Parse()

	if app.fprof != "" {
		fprof, err := os.Create(app.fprof)
		if err != nil {
			log.Fatalf("error creating pprof output file [%s]: %v\n",
				app.fprof,
				err,
			)
		}
		defer fprof.Close()
		pprof.StartCPUProfile(fprof)
		defer pprof.StopCPUProfile()
	}

	if app.ftrace != "" {
		ftrace, err := os.Create(app.ftrace)
		if err != nil {
			log.Fatalf("error creating trace output file: %v\n", err)
		}
		defer ftrace.Close()
		trace.Start(ftrace)
		defer trace.Stop()
	}

	fout, err := os.Create(app.fname)
	if err != nil {
		log.Fatalf("error creating output file [%s]: %v\n",
			app.fname,
			err,
		)
	}
	defer fout.Close()

	go app.write(fout)

	app.errc = make(chan error, app.nconc)
	app.resc = make(chan Result, app.nconc)

	go f(app)

	for i := 0; i < app.nevts; i++ {
		err := <-app.errc
		if err != nil {
			log.Fatalf("error: %v\n", err)
		}
	}
	close(app.resc)
	close(app.errc)

	err = fout.Close()
	if err != nil {
		log.Fatalf("error closing output file [%s]: %v\n",
			app.fname,
			err,
		)
	}
}
开发者ID:sbinet,项目名称:tmvl,代码行数:59,代码来源:app.go

示例7: main

func main() {
	trace.Start(os.Stderr)
	for i := 0; i < 360/10; i++ {
		go leaker()
	}
	time.Sleep(25 * time.Millisecond)
	trace.Stop()
}
开发者ID:divan,项目名称:talks,代码行数:8,代码来源:parallelism0.go

示例8: main

func main() {
	trace.Start(os.Stderr)
	for i := 0; i < 24; i++ {
		c := tick(100 * time.Millisecond)
		<-c
	}
	trace.Stop()
}
开发者ID:divan,项目名称:talks,代码行数:8,代码来源:timer_orig.go

示例9: main

func main() {
	trace.Start(os.Stderr)
	var wg sync.WaitGroup
	wg.Add(36)
	go pool(&wg, 36, 36)
	wg.Wait()
	trace.Stop()
}
开发者ID:yujinqiu,项目名称:gotrace,代码行数:8,代码来源:workers1.go

示例10: gofmtMain

func gofmtMain() {
	flag.Usage = usage
	paths := parseFlags()

	if *cpuProfile != "" {
		bw, flush := bufferedFileWriter(*cpuProfile)
		pprof.StartCPUProfile(bw)
		defer flush()
		defer pprof.StopCPUProfile()
	}
	if *traceProfile != "" {
		bw, flush := bufferedFileWriter(*traceProfile)
		trace.Start(bw)
		defer flush()
		defer trace.Stop()
	}
	if *memProfileRate > 0 {
		runtime.MemProfileRate = *memProfileRate
		bw, flush := bufferedFileWriter(*memProfile)
		defer func() {
			runtime.GC() // materialize all statistics
			if err := pprof.WriteHeapProfile(bw); err != nil {
				log.Fatal(err)
			}
			flush()
		}()
	}

	if *verbose {
		log.SetFlags(log.LstdFlags | log.Lmicroseconds)
		imports.Debug = true
	}
	if options.TabWidth < 0 {
		fmt.Fprintf(os.Stderr, "negative tabwidth %d\n", options.TabWidth)
		exitCode = 2
		return
	}

	if len(paths) == 0 {
		if err := processFile("<standard input>", os.Stdin, os.Stdout, true); err != nil {
			report(err)
		}
		return
	}

	for _, path := range paths {
		switch dir, err := os.Stat(path); {
		case err != nil:
			report(err)
		case dir.IsDir():
			walkDir(path)
		default:
			if err := processFile(path, nil, os.Stdout, false); err != nil {
				report(err)
			}
		}
	}
}
开发者ID:ChloeTigre,项目名称:golang-tools,代码行数:58,代码来源:goimports.go

示例11: traceHandlerGo17

func traceHandlerGo17(traceprofile string) {
	f, err := os.Create(traceprofile)
	if err != nil {
		Fatalf("%v", err)
	}
	if err := tracepkg.Start(f); err != nil {
		Fatalf("%v", err)
	}
	atExit(tracepkg.Stop)
}
开发者ID:achanda,项目名称:go,代码行数:10,代码来源:trace.go

示例12: main

func main() {
	var b bytes.Buffer
	trace.Start(&b)
	log.SetFlags(log.Ltime | log.Lshortfile)

	log.Println("first log output")
	log.Printf("second log output\n")
	fn()
	log.Printf("tace: %v\n", b.String())
}
开发者ID:ibmendoza,项目名称:golang-examples,代码行数:10,代码来源:debug.go

示例13: doTrace

func doTrace() func() {
	if *traceProfile != "" {
		bw, flush := bufferedFileWriter(*traceProfile)
		trace.Start(bw)
		return func() {
			flush()
			trace.Stop()
		}
	}
	return func() {}
}
开发者ID:vmware,项目名称:vic,代码行数:11,代码来源:goimports_gc.go

示例14: main

func main() {
	trace.Start(os.Stderr)
	runtime.GOMAXPROCS(1)
	in := make(chan int)
	out := make(chan int)
	go pool(in, out)
	go generate(in)
	print(out)
	trace.Stop()
	os.Exit(0)
}
开发者ID:divan,项目名称:talks,代码行数:11,代码来源:gomaxprocs1_orig.go

示例15: main

func main() {
	trace.Start(os.Stderr)
	runtime.GOMAXPROCS(24)
	in := make(chan int)
	out := make(chan int)
	go pool(in, out)
	go generate(in)
	go print(out)
	time.Sleep(1 * time.Second)
	trace.Stop()
}
开发者ID:divan,项目名称:talks,代码行数:11,代码来源:gomaxprocs24_orig.go


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