How to do profiling in C++

Please help I've to measure the time taken and the number of cpu clock cycles that were required by a C++ program to execute. Please explain how to do that and also attach a sample code if possible.
Thanks in advance
Topic archived. No new replies allowed.