gettimeofday will return time accurate to microseconds within the resolution of the system clock. You might also want to check out the High Res Timers project on SourceForge.
If you're on Intel hardware, here's how to read the CPU real-time instruction counter. It will tell you the number of CPU cycles executed since the processor was booted. This is probably the finest-grained, lowest overhead counter you can get for performance measurement.
Note that this is the number of CPU cycles. On linux you can get the CPU speed from /proc/cpuinfo and divide to get the number of seconds. Converting this to a double is quite handy.
When I run this on my box, I get
11867927879484732
11867927879692217
it took this long to call printf: 207485
High resolution is relative...
I was looking at the examples and they mostly cater for milliseconds.
However for me it is important to measure microseconds.
I have not seen a platform independant solution for microseconds and thought something like the code below will be usefull.
I was timing on windows only for the time being and will most likely add a gettimeofday() implementation when doing the same on AIX/Linux.