Link to home
Start Free TrialLog in
Avatar of vietpa
vietpaFlag for Viet Nam

asked on

Calculate the time different in milisecond or microsecond

I like to do the job above and i know time_t, unfortunately, in only result in second, and gettickcount() is for windows.
Anyone has the solution to do in Linux. Thanks in advance.
Avatar of Infinity08
Infinity08
Flag of Belgium image

>> gettickcount() is for windows.

You can use the standard clock() which will return the number of elapsed clock ticks :

        http://www.cplusplus.com/reference/clibrary/ctime/clock.html

Its granularity is generally a few milliseconds though. You can use the value CLOCKS_PER_SEC to know its granularity.
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vietpa

ASKER

@Infinity08: it seems works, may be the time different is to small, how to increase to microsec ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial