I’d like a way to measure C++ code as accurately as possible. I did see boost has a high resolution clock but the boost documentation says it’s an expensive clock in terms of performance- kinda defeating the purpose:
http://www.boost.org/doc/libs/1_47_0/doc/html/chrono/users_guide.html
What other ways are there? Is there any way to measure in CPU cycles??
I can’t tell from your question if you want external or internal profiling.
For external profiling, you have Quantify (or its successor) on Windows, and gprof on any unix with g++ and friends. If you use Solaris you even have dtrace, which you can attach to a running application to do statistical profiling.
If you’re looking for internal profiling,
gettimeofdayon Solaris/Linux should be quite performant enough for anything except inside a tight loop.