Reputation: 811
I need to calculate the time that a piece of my code takes to execute, right now I am using clock_t like so:
clock_t start = clock();
/* Do something here */
float executionTime = (clock()-(float)start) / CLOCKS_PER_SEC;
This works in the simulator, but when run on the device the value is always lower than what it should be. When running the simulator and my device at the same time the simulator finishes first but when my device finishes it has a shorter execution time.
The only difference between the simulator code and the device code is that a couple of functions are written in ARM assembly for the device.
In case this is relevant im using Xcode 4.1 and iOS 4.3.
Upvotes: 4
Views: 1070
Reputation: 811
It seems that after I rebooted my computer and my device clock() works again. Thanks to everyone that took the time to reply (:
Upvotes: 0
Reputation: 400592
Have you tried using either gettimeofday(2)
or mach_absolute_time()
instead?
Upvotes: 1