I am using TickCount() to determine the time difference between events or time required to run a certain piece of code. But it is deprecated in OS X 10.8.
Therefore, I needed an alternative for the same.
I am using TickCount() to determine the time difference between events or time required
Share
If you want to measure absolute time, use
gettimeofday(). This gives you the date, e.g., “Thu Nov 22 07:48:52 UTC 2012”. This is not always suitable for measuring differences between events because the time reported bygettimeofday()can jump forwards or backwards if the user changes the clock.If you want to measure relative time,
mach_absolute_time(). This lets you measure the difference between two events, e.g., “15.410 s”. This does not give absolute times, but is always monotonic.If you want to measure CPU time, use
clock(). This is often but not always the way you measure the performance of a piece of code. It doesn’t count time spent on IO, or impact on system speed, so it should only be used when you know you are measuring something CPU bound.I’m surprised that
TickCount()wasn’t deprecated earlier. It’s really an OS 9 and earlier thing.