Code run Time measurement method under Windows platform:
One: Millisecond level GetTickCount ()
#include <windows.h>
Second: Seconds-level time ()
#include <time.h>
Three: Microsecond level QueryPerformanceCounter (&end)
#include <windows.h>
Time measurement method under Linux platform:
One: seconds C language Library function time ()
Second: microsecond C language library function Gettimeofday ()
itself time consumption of about 3MS
Three: nanosecond-level RDTSC instruction timestamp timer
Intel Pentium above CPU, there is a part called "Time Stamp", it is in the format of 64-bit unsigned shaping, accurately records the number of clock cycles that have elapsed since the CPU was power up. The timestamp counter is in the machine clock unit. 1: Cycle = 1 sec/main frequency (Hz). These CPUs can be read using the RDTSC (read time Stamp Counter) instruction, which loads the high 32 bits of the timestamp counter into the edx register, and the low 32 bits are deposited in the EAX register. The RDTSC directive is not directly supported by the GCC inline assembly and can be embedded with a macro definition:
#define RDTSC ". Byte 0x0f, 0x31\n\t"