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