Documentation ¶
Overview ¶
Package profiling provides tools for recording frame timings for later analysis.
The simplest usage is to construct a profilier at the start of your event loop function and to defer stopping it until the window is closed. Something like:
func loop(w *app.Window) error { // log to a CSV file with a randomly-chosen name. The file's path will be // logged to stderr. recorder, err := NewRecorder(nil) if err != nil { // handle } defer recorder.Stop() var ops op.Ops for event := range window.Events() { switch event := event.(type) { case system.DestroyEvent: // returning will execute the deferred call to Stop(), which // flushes the CSV file. return event.Err case system.FrameEvent: gtx := layout.NewContext(&ops, event) // record the last frame's timing info and prepare the next one recorder.profile(gtx) // lay out your UI here } } }
The actual disk I/O is performed by a different goroutine and will not block the UI unless it gets more than 60 frames behind.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CSVTimingRecorder ¶
type CSVTimingRecorder struct {
// contains filtered or unexported fields
}
CSVTimingRecorder captures frame timing information into a CSV file
func NewRecorder ¶
func NewRecorder(filename *string) (*CSVTimingRecorder, error)
NewRecorder creates a CSVTimingRecorder that will record to a CSV file with the provided name. If the name is nil, a temporary file will be used.
func (*CSVTimingRecorder) Profile ¶
func (c *CSVTimingRecorder) Profile(gtx layout.Context)
Profile records profiling data from the last frame and prepares the capture of the next frame. Calling this method every frame is sufficient to profile all frames. It will simply return if c is nil.
func (*CSVTimingRecorder) Stop ¶
func (c *CSVTimingRecorder) Stop() error
Stop shuts down the recording process and flushes all data to the CSV file.