[macOS] Profiling — visualize program bottleneck with Flamegraph
<p>This article is a follow up on the previous <a href="https://medium.com/@techhara/profiling-visualize-program-bottleneck-with-flamegraph-3e0c5855b2fe" rel="noopener">article</a> that describes how to obtain Flamegraph on Linux. Today, let’s do the same for macOS platform.</p>
<p>The first difference is that on macOS, there is no <code>perf</code> utility, as it is specific to Linux. One can use <code>dtrace</code> as an alternative, but then macOS has system integrity protection (SIP) feature that blocks collecting system calls. A better alternative is to use Apple’s own profiling tool, <a href="https://help.apple.com/instruments/mac/current/#/" rel="noopener ugc nofollow" target="_blank">Instruments</a>. Unfortunately, this is intended as a GUI app, so it’s hard to make a script and automate things, but the good news is that at least it is doable.</p>
<p>First, make sure to install Instruments by installing <a href="https://apps.apple.com/us/app/xcode/id497799835?mt=12" rel="noopener ugc nofollow" target="_blank">XCode</a>. Make sure you can run <code>xctrace</code>, which should output shown below</p>
<p><a href="https://medium.com/@techhara/profiling-visualize-program-bottleneck-with-flamegraph-macos-4a2b3598df8a"><strong>Visit Now</strong></a></p>