From charlesreid1

Shark is a profiler for Mac. It has a nice GUI interface.

Shark works much different from other profilers like gprof. Basically, you run Shark, tell it to start gathering data, then you run your program like normal. Shark gathers information on every single process happening on the system.

It is arguable whether this is a good approach or not, but that's not really the point of this article.


Timing Profiles

You can use a timing profile to determine how much time is spent in various system and function calls. This is useful for developing a sense of which particular lines or functions in the code are taking most of the computational time.

Gathering Timing Data

Shark1.png

Start Shark and pick "Time Profile."

Shark2.png

When you press "Start," Shark will begin to gather data. This is when you run your program.

Shark3.png

Once you've finished gathering data, you can press "Stop" and Shark will start to process your data.

Shark4.png

After it finishes processing the data, it will show you all the different processes that were taking place on your system, and how much time each one took.