I have some 8086 assembly code that’s going to be calling interrupts for reading and writing files. I’m using TASM to link and build my project. What options are available to me to time how long it takes to execute? I don’t think counting clock cycles will work if I’m waiting on hard drive read times.
EDIT: For software recommendations, I should tell you that I’m running Windows 7.
It depends on how accurate you want to get, and how much trouble you want to go to.
You say you’re calling interrupts for reading and writing files. I assume you’re doing the old INT 21H interrupt functions. INT 21H Function 2Ch returns the time of day, accurate to about 5/100 seconds. See http://spike.scu.edu.au/~barry/interrupts.html#ah2c for more info.
If you can call Windows API functions, then you can call
QueryPerformanceCounterto get the tick count at the beginning of the code you want to time. Call the function again afterwards, subtract the start from the end, and then divide the result by the return value fromQueryPerformanceFrequency, and you’ve got it.Of course, that requires doing 64-bit arithmetic.
You can call the
GetSystemTimeAPI function, passing it aSYSTEMTIMEstructure that gets populated. Or you can calltimeGetTime, which returns the number of milliseconds since the computer was started. You have to be careful with this one, because it will roll over after 49 days.There are probably other ways to go, too. But the simplest, if you’re calling INT 21H functions, is to just use function 2CH.