This is LapTimer.m in view mode; [Download] [Up]
/*
** Copyright (c) 1995 Friday Software & Consulting, Inc. All Rights Reserved.
**
** Author: <bbum@friday.com>
*/
/* This object is included in the MiscKit by permission from the author
** and its use is governed by the MiscKit license, found in the file
** "LICENSE.rtf" in the MiscKit distribution. Please refer to that file
** for a list of all applicable permissions and restrictions.
*/
#import <sys/time.h>
#import <objc/Object.h>
#import "LapTimer.h"
@implementation LapTimer
- (void)start
{
gettimeofday(&startTime, &tzp);
}
- (void)lap;
{
gettimeofday(&lapTime, &tzp);
}
- (void)stop;
{
gettimeofday(&endTime, &tzp);
}
- (unsigned long) lapMicroseconds
{
unsigned long secondsDiff = lapTime.tv_sec - startTime.tv_sec;
unsigned long usecDiff = lapTime.tv_usec - startTime.tv_usec;
return (secondsDiff * 1000000) + usecDiff;
}
- (unsigned long) totalMicroseconds
{
unsigned long secondsDiff = endTime.tv_sec - startTime.tv_sec;
unsigned long usecDiff = endTime.tv_usec - startTime.tv_usec;
return (secondsDiff * 1000000) + usecDiff;
}
- (double) lapSeconds
{
unsigned long usecdiff = [self lapMicroseconds];
return ((double)usecdiff) / 1000000.;
}
- (double) totalSeconds
{
unsigned long usecdiff = [self totalMicroseconds];
return ((double)usecdiff) / 1000000.;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.