How to get execution time of a function in microsecs?
-
Hi, I want to measure elapsed time of a function in microsecs how to do that. I tried with clock()(output is in seconds/ millisec),GetTickCount() (in millisec) the output is in secs or millisecs,i need in microsecs.Is there any function in VC++? Thanks
-
Hi, I want to measure elapsed time of a function in microsecs how to do that. I tried with clock()(output is in seconds/ millisec),GetTickCount() (in millisec) the output is in secs or millisecs,i need in microsecs.Is there any function in VC++? Thanks
shir_k wrote:
I tried with clock()(output is in seconds/ millisec),GetTickCount() (in millisec) the output is in secs or millisecs,i need in microsecs.Is there any function in VC++?
try QueryPerformanceCounter (Multimedia Timers)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
shir_k wrote:
I tried with clock()(output is in seconds/ millisec),GetTickCount() (in millisec) the output is in secs or millisecs,i need in microsecs.Is there any function in VC++?
try QueryPerformanceCounter (Multimedia Timers)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
Not without calling
QueryPerformanceFrequency(...)
first to make sure that [1] the HR timer is available and [2] that it supports microsecond-level resolution... Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFiles -
Hi, I want to measure elapsed time of a function in microsecs how to do that. I tried with clock()(output is in seconds/ millisec),GetTickCount() (in millisec) the output is in secs or millisecs,i need in microsecs.Is there any function in VC++? Thanks
You may also be able to get suitable timing information using the
RDTSC
instruction. Google for it for more details. If the function will not be running across multiple physical or logical CPUs (its affinity is locked to one CPU, or it is running in a single-CPU system), and will not be running across a sleep/hybernation operation, it should be accurate enough. Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFiles -
Not without calling
QueryPerformanceFrequency(...)
first to make sure that [1] the HR timer is available and [2] that it supports microsecond-level resolution... Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFilesJames R. Twine wrote:
first to make sure that [1] the HR timer is available and [2] that it supports microsecond-level resolution...
right as usual :)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You