A minimal function-level profiler for local testing

Revision en2, by amit_dwivedi, 2025-05-21 08:16:38

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!

Tags codeforces tools, c++, local, time

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English amit_dwivedi 2025-05-21 08:16:38 16 Tiny change: ' summary="How to run?">\n```bas' -> ' summary="Command">\n```bas'
en1 English amit_dwivedi 2025-05-21 08:15:38 2804 Initial revision (published)