How to time benchmarks on a Macintosh.

The TickCount function returns the time that has elapsed since the Macintosh was turned on, in sixtieths of a second.

From C or C++:

#include <Events.h>
pascal unsigned long TickCount(void);

From Pascal:

FUNCTION TickCount: LongInt;

For more information, see Inside Macintosh: Macintosh Toolbox Essentials, page 2-112.


How to time benchmarks under Unix (tested under SunOS).

#include <sys/time.h>
#include <sys/resource.h>

long timenow();

/* Returns user time in milliseconds since start of process */

long timenow()
{
  struct rusage r;

  getrusage( RUSAGE_SELF, &r );
  return (r.ru_utime.tv_sec * 1000 + r.ru_utime.tv_usec / 1000);
}