Linked Questions
146 questions linked to/from How to get the CPU cycle count in x86_64 from C++?
23 votes
4 answers
57k views
How to count clock cycles with RDTSC in GCC x86? [duplicate]
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 #...
5 votes
2 answers
3k views
making mistake in inline assembler in gcc [duplicate]
I have successfully written some inline assembler in gcc to rotate right one bit following some nice instructions: http://www.cs.dartmouth.edu/~sergey/cs108/2009/gcc-inline-asm.pdf Here's an example: ...
6 votes
1 answer
1k views
"rdtsc": "=a" (a0), "=d" (d0) what does this do? [duplicate]
I'm new to C++ and benchmarking I don't understand what the this part of the code does? So I found something about the edx, eax registers, but I don't fully understand how that plays into the code. ...
3 votes
1 answer
1k views
How can I convert this assembly timestamp function to C++? [duplicate]
I am trying to convert someone else's project from 32bit to 64bit. Everything seems to be OK except one function, which uses assembly expressions which are not supported in Visual Studio when building ...
2 votes
1 answer
5k views
CPU cycle count c++ [duplicate]
Possible Duplicate: Getting cpu cycles using RDTSC - why does the value of RDTSC always increase? Get CPU cycle count? I want to write C++ code which analyzes sorting algorithms, and I need to ...
1 vote
1 answer
4k views
Undefined reference to rdtsc [duplicate]
I'm writing code that creates trees and times different methods of creating trees. I can't seem to get rdtsc to function properly, though. Here's my code: #include <stdio.h> #include &...
2 votes
2 answers
291 views
what is the C++ equivalent for this assembly code [duplicate]
I'm trying to figure out how to read this assembly code in C++. This is the code: unsigned __int64 high_perf_time; unsigned __int64 *dest = &high_perf_time; __asm { _emit 0xf // these ...
0 votes
1 answer
872 views
Using `rdtsc`: error C2065 [duplicate]
I'm trying to generate random numbers but with this seed int rdtsc() { __asm__ __volatile__("rdtsc"); } But when I try to compile I get this error: error C2065: '__asm__' : ...
1 vote
1 answer
804 views
rdtsc() giving strange results [duplicate]
I have written a very simple C program in an attempt to understand rdtsc in C (Linux).The program is given below. #include <stdio.h> static inline unsigned long long tick() { unsigned ...
0 votes
1 answer
692 views
GCC Windows __asm RDTSC clobber [duplicate]
So I'm trying compile some C in GCC for windows. Long story short I can't get Visual Studios to compile an EXE that works on XP. So I thought I'd give GCC a try. The code it's struggling with is: ...
1 vote
0 answers
500 views
How to use the output of RDTSC [duplicate]
My code is very simple: global start extern printf, Sleep section .data: string db 'End: %llu', 0Ah, 'Start: %llu', 0 section .text: start: mfence lfence rdtsc sub rsp, 8 ...
0 votes
1 answer
168 views
Calling cpuid before rdtsc to prevent out of order? [duplicate]
I am trying to call cpuid before my rdtsc function to prevent out of order. I initially used this rdtsc function to get 2 timestamps and often I get negative numbers, which is undesirable. This is the ...
0 votes
0 answers
210 views
c++ how to write function to measure function performance using time stamp counter [duplicate]
i am not sure how a function that will read the Intelx86 Time stamp counter would look like. i'm trying to measure the performance of a single function so I assume that I would need 2 functions: 1 - ...
0 votes
0 answers
96 views
What am I doing wrong in measuring execution time using RDTSC and CPUID instructions? [duplicate]
I'm a C++ student and I was assigned to measure the time of memory allocation of 1.000.000 integers, using CPUID and RDTSC instructions in inline assembly for G++ compiler. Here is the code I came up ...
1 vote
0 answers
77 views
What is the difference between inline assembly call and direct call? [duplicate]
What is the difference between using thet= __rdtsc() function directly and using asm __volatile__ ( "rdtsc \n" : "=a" (t)); I have seen on ...