mirror of
https://github.com/golang/go
synced 2024-11-06 02:26:17 -07:00
27 lines
483 B
Go
27 lines
483 B
Go
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a BSD-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
|
// +build gc
|
||
|
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"flag"
|
||
|
"runtime/trace"
|
||
|
)
|
||
|
|
||
|
var traceProfile = flag.String("trace", "", "trace profile output")
|
||
|
|
||
|
func doTrace() func() {
|
||
|
if *traceProfile != "" {
|
||
|
bw, flush := bufferedFileWriter(*traceProfile)
|
||
|
trace.Start(bw)
|
||
|
return func() {
|
||
|
flush()
|
||
|
trace.Stop()
|
||
|
}
|
||
|
}
|
||
|
return func() {}
|
||
|
}
|