hi, how can i do this?
i tried using gettickcount of windows.h and also the clock function in time.h but none worked, it gave 0 as a result
thanks in advance
hi, how can i do this?
i tried using gettickcount of windows.h and also the clock function in time.h but none worked, it gave 0 as a result
thanks in advance
on windows you can try using QueryPerformanceCounter(). a simple example follows:
Code:LARGE_INTEGER frequency; LARGE_INTEGER before, after; QueryPerformanceFrequency(&frequency); QueryPerformanceCounter(&before); // call function here QueryPerformanceCounter(&after); double seconds = double(after - before) / double(frequency);
Last edited by Elkvis; 03-11-2011 at 03:59 PM. Reason: removed unnecessary variables
You can try this one:
I'm not sure if it is what you want, but I hope it works, i'm having a compiler problem and i couldn't test it.Code:int example(void) { DWORD start_time=GetTickCount(); ///learn the time at start ///do some stuff here return GetTickCount()-start_time; //calculate how much time has passed and return it. }
i tried the gettickcount but for some reason it didnt return anything except 0
as for QueryPerformanceCounter
i tried your code, but it didnt work i put for before, after and frequency a .QuadPart and it did work, does anyone know why?
could you post the function so that i could help?