方法1:
clock_t begin = clock();
//…
clock_t end = clock();
cout << "execute time = " << (end - begin) / CLOCKS_PER_SEC << “s” << endl;
IOS方法2:
CFAbsoluteTime beginTime = CFAbsoluteTimeGetCurrent();
CFDateRef beginDate = CFDateCreate(kCFAllocatorDefault, beginTime);
// …
CFAbsoluteTime endime = CFAbsoluteTimeGetCurrent();
CFDateRef endDate = CFDateCreate(kCFAllocatorDefault, endTime);
CFTimeInterval timeInterval = CFDateGetTimeIntervalSinceDate(endDate, beginDate);
cout << "execure time = " << (double)(timeInterval) * 1000.0 << “ms” << endl;
更多方法详见
https://www.cnblogs.com/dwdxdy/p/3214905.html