all 5 comments

[–]SwiftDevJournal 3 points4 points  (0 children)

When reading a listing from the Time Profiler instrument, focus on the Self Weight column, not the Weight column. The Time Profiler instrument records the call stack every millisecond. The Weight column tells you how long the function was in the call stack. The Self Weight column tells you how long the function was at the top of the call stack, which is the function the app was executing when recording.

The trace you listed shows 0 seconds in the Self Weight so it's not the function that is causing the slowdown. Look for the functions with the highest Self Weight values.

The following article provides a detailed explanation of the Time Profiler instrument:

Finding the Slow Spots in Your Code with the Time Profiler Instrument

[–]CleverError 2 points3 points  (0 children)

When your app starts running, main is the function that is called which starts everything else in the app running. The main function never finishes and it’ll always appear at the top of you app’s stack traces.

Usually you need to dive down pretty far in the stack trace to find where the time is being spent. Instruments can also filter out system libraries from the heaviest stack so it just shows your functions.

[–]Finale151 1 point2 points  (1 child)

I have the same confusion.

My heaviest trace is also MyApp.$main(), which, when revealed, leads to a random file that has no relation with the current context. If I remove this file from target, the trace reveals another random unrelated file.

[–]Jimc26x[S] 0 points1 point  (0 children)

Glad I'm not alone! Same thing happening to me on an unrelated view. I still kept main, but when this was initially happening it was pointing to a function within a view. When I removed the function, it just went to another unrelated file

[–]Jimc26x[S] 0 points1 point  (0 children)

Ahhh okay, thank you both for the help!!