How to count clock cycles with RDTSC in GCC x86? [duplicate]
问题 This question already has answers here : How to get the CPU cycle count in x86_64 from C++? (4 answers) Closed last year . With Visual Studio I can read the clock cycle count from the processor as shown below. How do I do the same thing with GCC? #ifdef _MSC_VER // Compiler: Microsoft Visual Studio #ifdef _M_IX86 // Processor: x86 inline uint64_t clockCycleCount() { uint64_t c; __asm { cpuid // serialize processor rdtsc // read time stamp counter mov dword ptr [c + 0], eax mov dword ptr [c +