Re: NSNull and distinct objective-C type
Re: NSNull and distinct objective-C type
- Subject: Re: NSNull and distinct objective-C type
- From: email@hidden
- Date: Thu, 4 Jun 2009 06:39:56 -0600 (MDT)
- Importance: Normal
Hello All,
I am facing an issue in use of mach_absolute_time().
mach_absolute_time() gives drift even when NTP timing update is on.
Please see my code below:
#import <Cocoa/Cocoa.h>
#import <mach/mach_time.h>
nt main(int argc, char *argv[])
{
uint64_t nowTime = mach_absolute_time();
uint64_t drift = 0;
for (int i=0;i<1000;i++)
{
sleep(5);
uint64_t current_Time = mach_absolute_time();
uint64_t differenceTime = (current_Time - nowTime)*1E-6;
drift = differenceTime - (i+1)*5000;
NSLog(@"Elapsed Time =%lld",differenceTime);
NSLog(@"drift =%lld",drift);
}
return 1;
//return NSApplicationMain(argc, (const char **) argv);
}
Expected Results:
I expected to see zero drift in the print. After several runs, the drift
kept on increasing
Actual Results:
Below are actual results
009-06-04 17:49:49.936 TestMachSleep[3275:10b] Elapsed Time =5000
2009-06-04 17:49:49.939 TestMachSleep[3275:10b] drift =0
2009-06-04 17:49:54.940 TestMachSleep[3275:10b] Elapsed Time =10004
2009-06-04 17:49:54.942 TestMachSleep[3275:10b] drift =4
2009-06-04 17:49:59.943 TestMachSleep[3275:10b] Elapsed Time =15007
2009-06-04 17:49:59.944 TestMachSleep[3275:10b] drift =7
2009-06-04 17:50:04.947 TestMachSleep[3275:10b] Elapsed Time =20011
2009-06-04 17:50:04.950 TestMachSleep[3275:10b] drift =11
2009-06-04 17:50:09.954 TestMachSleep[3275:10b] Elapsed Time =25018
2009-06-04 17:50:09.965 TestMachSleep[3275:10b] drift =18
2009-06-04 17:50:14.976 TestMachSleep[3275:10b] Elapsed Time =30040
2009-06-04 17:50:14.991 TestMachSleep[3275:10b] drift =40
2009-06-04 17:50:20.003 TestMachSleep[3275:10b] Elapsed Time =35068
2009-06-04 17:50:20.004 TestMachSleep[3275:10b] drift =68
2009-06-04 17:50:25.012 TestMachSleep[3275:10b] Elapsed Time =40076
2009-06-04 17:50:25.031 TestMachSleep[3275:10b] drift =76
2009-06-04 17:50:30.041 TestMachSleep[3275:10b] Elapsed Time =45105
2009-06-04 17:50:30.046 TestMachSleep[3275:10b] drift =105
2009-06-04 17:50:35.064 TestMachSleep[3275:10b] Elapsed Time =50129
2009-06-04 17:50:35.073 TestMachSleep[3275:10b] drift =129
2009-06-04 17:50:40.091 TestMachSleep[3275:10b] Elapsed Time =55156
2009-06-04 17:50:40.092 TestMachSleep[3275:10b] drift =156
2009-06-04 17:50:45.104 TestMachSleep[3275:10b] Elapsed Time =60169
2009-06-04 17:50:45.112 TestMachSleep[3275:10b] drift =169
2009-06-04 17:50:50.133 TestMachSleep[3275:10b] Elapsed Time =65198
2009-06-04 17:50:50.136 TestMachSleep[3275:10b] drift =198
2009-06-04 17:50:55.137 TestMachSleep[3275:10b] Elapsed Time =70202
2009-06-04 17:50:55.138 TestMachSleep[3275:10b] drift =202
2009-06-04 17:51:00.147 TestMachSleep[3275:10b] Elapsed Time =75212
2009-06-04 17:51:00.160 TestMachSleep[3275:10b] drift =212
I need millisecond accuracy to send time to server after certain activity
has been done. I understand that sleep is not millisecond accurate but I
was not expecting to see a progressively increasing drift.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden