Main Page   Class Hierarchy   Compound List   File List   Header Files   Compound Members   File Members  

timer.h

This is the verbatim text of the timer.h include file.
/* 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"  

};


Generated at Tue Jun 27 12:07:20 2000 for SelfVM by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999