amit_dwivedi's blog

By amit_dwivedi, history, 12 months ago, In English

Could not make GNU gprof work on my mac. So I wrote my own profiler for C++.

It prints a neatly-indented time tree for every function's entry and exit.

Example.
Given a sample code like

this

It produces

this

I’ve pushed the code and usage details to to Github.

How to Run?

Command
At a glance
  • Zero code changes inside your solution.
  • Skip profiling all the std:: calls. (This was super tricky to achieve.)
  • Overhead ≈ 50–100 ns per call.
  • POSIX only (dladdr system call), Won't work in windows.
  • Tested on GCC 14.
  • Multithreaded code or recursion will be hard to analyse.

Feedback and pull requests are welcome.

Peace!

  • Vote: I like it
  • +18
  • Vote: I do not like it