Debugging
Ce contenu n’est pas encore disponible dans votre langue.
This guide demonstrates various tools for inspecting and investigating possible performance issues within your Wails app using
runtime/traceto create performance graphs and inspect them in a browser
Creating performance traces
Section titled “Creating performance traces”-
Prepare your app for Tracing
Close to your program entrypoint, ensure code along the following lines exists
// Create the file to store our trace data withintraceFile, err := os.Create("trace.out")if err != nil {log.Fatalf("trace.out could not be created: %v", err)}// Start the traceif err := trace.Start(traceFile); err != nil {_ = traceFile.Close()log.Fatalf("trace.start could not start: %v", err)}// Trace cleanup on exit. Alternatively,defer func() {trace.Stop()_ = traceFile.Close()}()...Start your wails app here...Output will be saved to
trace.outwithin your working path with metrics covering the complete runtime of your app. The default trace is quite raw; you are well advised to do further reading on trace to add more contextual information and limit what you actually record. For example:WithRegion, NewTask, Log -
Run your app to create the trace
With your app running, a continuous trace will be produced up to the point of exit so go ahead and perform some actions in your app and exit when complete
-
Install Visualisation helpers
Some views need Graphviz. You can verify it is installed by running
dot -VTerminal window # macOSbrew install graphviz# Ubuntu/Debiansudo apt-get install graphviz# Archsudo pacman -S graphviz -
Visualize your trace
With your trace data available, we can start up the web interface
Terminal window go tool trace trace.outThis should open up your default browser (recommended to use Chrome-based) with the trace event viewer home page.
For first-time users, the
Syscall profilescreen is probably the most useful. This provides a breakdown of exactly what the program is doing along with timings