本文整理汇总了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()
}
示例2: main
func main() {
trace.Start(os.Stderr)
for i := 0; i < 1000; i++ {
go leaker()
}
trace.Stop()
}
示例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()
}
示例4: traceStop
func (t *logicTest) traceStop() {
if t.traceFile != nil {
trace.Stop()
t.traceFile.Close()
t.traceFile = nil
}
}
示例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)
}
示例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,
)
}
}
示例7: main
func main() {
trace.Start(os.Stderr)
for i := 0; i < 24; i++ {
c := tick(100 * time.Millisecond)
<-c
}
trace.Stop()
}
示例8: main
func main() {
trace.Start(os.Stderr)
var wg sync.WaitGroup
wg.Add(36)
go pool(&wg, 36, 36)
wg.Wait()
trace.Stop()
}
示例9: main
func main() {
trace.Start(os.Stderr)
for i := 0; i < 360/10; i++ {
go leaker()
}
time.Sleep(25 * time.Millisecond)
trace.Stop()
}
示例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)
}
}
}
}
示例11: doTrace
func doTrace() func() {
if *traceProfile != "" {
bw, flush := bufferedFileWriter(*traceProfile)
trace.Start(bw)
return func() {
flush()
trace.Stop()
}
}
return func() {}
}
示例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()
}
示例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)
}
示例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)
}
}
示例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()
}