03_trace

command
v0.0.0-...-baf0b24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2020 License: MIT Imports: 12 Imported by: 0

README

With Trace Enabled

Finally the actual sequence of events. This is the same program with just additional being the trace output.

...
  // Create a Trace File
	fl, err := os.Create("t.out")
	if err != nil {
		panic(err)
	}
	defer fl.Close()
	// Begin CPU Profiling
	trace.Start(fl)
	defer trace.Stop()
...

Here the file t.out would be used for trace.

To invoke the Trace tool

$ go tool trace t.out
2019/02/13 13:28:08 Parsing trace...
2019/02/13 13:28:08 Splitting trace...
2019/02/13 13:28:08 Opening browser. Trace viewer is listening on http://127.0.0.1:50299

This would open the link http://127.0.0.1:50299 in your default browser.

IMPORTANT: For trace to work you need to open the link in Chrome

Conclusion

Here we are able to see the real performance metrics. We can also observe that not all the cores in the PC are being used. This would then help us optimize the performance of goroutines

We are still unable to see the boundary of the execution since most of the time. Next we would look at Regions in trace.

Documentation

Overview

* After running the program

Use command to view Trace on Chrome:

go tool trace t.out

Make sure its Chrome as the Trace only works in Chrome

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL