//模拟windows下 GetTickCount //
//#import<mach/mach_time.h>
+ (int)mxGetTickCount;
{
int timeTick;
mach_timebase_info_data_t info;
uint64_t machineTime;
mach_timebase_info(&info);
machineTime =mach_absolute_time();
timeTick = machineTime * info.numer / info.denom /1000000LL;
return timeTick;
}
// NSDate timeIntervalSinceDate:
//下面转换NSString,用在保存时间时使用。
- (double)GetStringTimeDiff:(NSString*)timeS timeE:(NSString*)timeE
{
double timeDiff = 0.0;
NSDateFormatter *formatters = [[NSDateFormatter alloc] init];
[formatters setDateFormat:@"yyyy/MM/dd HH:mm:ss:SSS"];
NSDate *dateS = [formatters dateFromString:timeS];
NSDateFormatter *formatterE = [[NSDateFormatter alloc] init];
[formatterE setDateFormat:@"yyyy/MM/dd HH:mm:ss:SSS"];
NSDate *dateE = [formatterE dateFromString:timeE];
timeDiff = [dateE timeIntervalSinceDate:dateS ];
return timeDiff;
}
- (NSString*)GetCurTime
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy/MM/dd HH:mm:ss:SSS"];
NSString*timeString=[formatter stringFromDate: [NSDate date]];
[formatter release];
return timeString;
}