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


Golang trace.Stop函数代码示例

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


在下文中一共展示了Stop函数的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)
	for i := 0; i < 1000; i++ {
		go leaker()
	}
	trace.Stop()
}
开发者ID:divan,项目名称:talks,代码行数:7,代码来源:leak.go

示例3: 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

示例4: traceStop

func (t *logicTest) traceStop() {
	if t.traceFile != nil {
		trace.Stop()
		t.traceFile.Close()
		t.traceFile = nil
	}
}
开发者ID:GitGoldie,项目名称:cockroach,代码行数:7,代码来源:logic_test.go

示例5: 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

示例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 < 24; i++ {
		c := tick(100 * time.Millisecond)
		<-c
	}
	trace.Stop()
}
开发者ID:divan,项目名称:talks,代码行数:8,代码来源:timer_orig.go

示例8: 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

示例9: 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

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

示例12: 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

示例13: 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

示例14: MakeTrace

// MakeTrace POST Trace binaries to the deferpanic website
func (c *DeferPanicClient) MakeTrace(commandId int, agent *Agent) {
	var buf []byte
	buffer := bytes.NewBuffer(buf)

	c.Lock()
	c.RunningCommands[commandId] = true
	c.Unlock()
	defer func() {
		c.Lock()
		delete(c.RunningCommands, commandId)
		c.Unlock()
	}()

	log.Println("trace started")
	err := trace.Start(buffer)
	if err != nil {
		log.Println(err)
		return
	}

	select {
	case <-time.After(30 * time.Second):
		trace.Stop()
		log.Println("trace finished")

		out := make([]byte, len(buffer.Bytes()))
		copy(out, buffer.Bytes())
		pkgpath, err := filepath.Abs(os.Args[0])
		if err != nil {
			log.Println(err)
			return
		}
		pkg, err := ioutil.ReadFile(pkgpath)
		if err != nil {
			log.Println(err)
			return
		}
		crc32 := crc32.ChecksumIEEE(pkg)
		size := int64(len(pkg))
		if agent.CRC32 == crc32 && agent.Size == size {
			pkg = []byte{}
		}
		t := NewTrace(out, pkg, commandId, false)

		b, err := json.Marshal(t)
		if err != nil {
			log.Println(err)
			return
		}

		c.Postit(b, traceUrl, false)
	}
}
开发者ID:betacraft,项目名称:deferclient,代码行数:54,代码来源:go15_trace.go

示例15: main

func main() {
	trace.Start(os.Stderr)
	var Ball int
	table := make(chan int)

	go player(table)
	go player(table)

	table <- Ball
	time.Sleep(1 * time.Second)
	<-table
	trace.Stop()
}
开发者ID:yujinqiu,项目名称:gotrace,代码行数:13,代码来源:pingpong01.go


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