/* Sun-$Revision: 23.4 $ */
/* Copyright 1992-9 Sun Microsystems, Inc. and Stanford University.
See the LICENSE file for license information. */
# pragma interface
// Timers for simple measurements
struct timer { // measures user CPU time in ms
int32 user_time;
timer() {}
void start() { user_time = OS::cpu_time(); }
int32 time() { return OS::cpu_time() - user_time; }
int32 secs() { return (time() + 500) / 1000; }
int32 millisecs() { return time(); }
int32 timeRestart() { int32 t = time(); start(); return t; }
int32 secsRestart() { return (timeRestart() + 500) / 1000; }
};
struct startTimer: timer {
startTimer() { start(); }
};
// portable version: must be subclassed:
class ElapsedTimer { // measures elapsed time in us
private:
bool is_running;
static const long one_million;
static const float one_thousand;
public:
ElapsedTimer(bool start_timer = false) { init(start_timer); }
void reset();
void start();
void stop();
float millisecs();
fint secs();
void print();
private:
void init(bool start_timer);
void reset_platform();
# include "_timer_pd.h.incl"
};