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.