Permalink
Browse files

Use PRHAbsoluteTimeToNanoseconds in the timing comparator.

  • Loading branch information...
1 parent 344abbc commit 02c01d7fb1c2654927d0b855e9f541760d70a8cd Peter Hosey committed Nov 24, 2011
Showing with 3 additions and 3 deletions.
  1. +3 −3 libtiming/libtiming.m
View
6 libtiming/libtiming.m
@@ -9,6 +9,7 @@
#import "libtiming.h"
#import "PRHTimingBlockRecord.h"
+#import "PRHAbsoluteTimeToNanoseconds.h"
PRHTimingReturnBlock PRHTimingLogToConsoleReturnBlock = ^(NSString *name, NSUInteger iterations, NSTimeInterval timeTaken, NSTimeInterval timePerIteration) {
NSLog(@"%@ ran %lu times in %f seconds (%f microseconds per iteration)", name, iterations, timeTaken, timePerIteration * USEC_PER_SEC);
@@ -110,11 +111,10 @@ - (void) startWithReturnBlock:(PRHTimingReturnBlock)returnBlock {
mach_timebase_info_data_t timebase;
kern_return_t err = mach_timebase_info(&timebase);
NSAssert(err == KERN_SUCCESS, @"mach_timebase_info returned %i", err);
- NSTimeInterval nanosecondsPerAbsoluteTimeUnit = (NSTimeInterval)timebase.numer / (NSTimeInterval)timebase.denom;
- uint64_t timeLimitInAbsoluteTime = (self.timeLimit * NSEC_PER_SEC) / nanosecondsPerAbsoluteTimeUnit;
+ uint64_t timeLimitInAbsoluteTime = PRHSecondsToAbsoluteTime(self.timeLimit);
softDeadline = startTime + timeLimitInAbsoluteTime;
int64_t timeLimitHeadroomInNanoseconds = (self.timeLimitHeadroom * NSEC_PER_SEC);
- uint64_t timeLimitHeadroomInAbsoluteTime = timeLimitHeadroomInNanoseconds / nanosecondsPerAbsoluteTimeUnit;
+ uint64_t timeLimitHeadroomInAbsoluteTime = PRHNanosecondsToAbsoluteTime(timeLimitHeadroomInNanoseconds);
totalTimeLimit = timeLimitInAbsoluteTime + timeLimitHeadroomInAbsoluteTime;
{

0 comments on commit 02c01d7

Please sign in to comment.