I have a Windows 10 computer and Visual Studio 2017 for my C/C++ development.
I am currently reading "Code Optimization: Effective Memory Usage" and the author suggest running the following code to capture accurate run times of various codes.
XOR EAX, EAX ;CPUID command is called to ensure all preceding commands
CPUID ;have left the pipeline, hence, not influencing measurement results
RDTSC ;This returns to the EAX register the lower DWord of current
;value of time stamp counter
MOV [clock], EAX ; the obtained result is save to the clock variable
//...
//profiled code ; here the profiled code is run
//---
XOR EAX, EAX ; the CPUID command is executed again to ensure all preceding
CPUID ;instructions have left the pipeline
RDTSC ; read the new value of the time stamp counter
SUB EAX, [clock] ; calculate the difference to capture actual time to execute code fragment
I can understand what the above assembly code is doing. But where exactly do I type this in in Windows and observe the results? Should I be saving this as a .asm file in Visual studio and then running it within that? Should I create a C file and then include this assembly instructions within it? Or, should I stay away from Visual Studio completely and use a stand alone Assembly Language compiler/debugger?