What techniques can you use to profile your code


Some of the platforms that I develop on, don't have profiling tools. I am looking for suggestions/techniques that you have personally used to help you identify hotspots, without the use of a profiler.

The target language is C++.

I am interested in what you have personally used.

I've found the following quite useful:

# define PROFILE_CALL(x) do{ \
    const DWORD t1 = timeGetTime(); \
    x; \
    const DWORD t2 = timeGetTime(); \
    std::cout << "Call to '" << #x << "' took " << (t2 - t1) << " ms.\n"; \
# define PROFILE_CALL(x) x

Which can be used in the calling function as such:

int r = 0;
PROFILE_CALL(r = readPacketSize());