home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / presto / prest_04.lha / src / unix / timer.c < prev   
Encoding:
C/C++ Source or Header  |  1989-06-06  |  624 b   |  52 lines

  1.  
  2. /*
  3.  * Unix support for timer object.
  4.  *
  5.  */
  6. #include "presto.h"
  7.  
  8. void
  9. Timer::init()
  10. {
  11.     t_starttime = getabsolutetime();
  12. }
  13.  
  14. Timer::~Timer()
  15. {
  16. }
  17.  
  18.  
  19. double
  20. Timer::getabsolutetime()
  21. {
  22.     struct timeval *t_tv;
  23.     t_tv = gettimeofday();
  24.     return (double)t_tv->tv_sec +
  25.         ((double)(t_tv->tv_usec) * 1.0e-6);
  26. }
  27.  
  28. char*
  29. Timer::getasciitime()
  30. {
  31.     struct timeval *t_tv;
  32.     t_tv = gettimeofday();
  33.     return ctime((long*)&t_tv->tv_sec);
  34. }
  35.  
  36.  
  37.  
  38.  
  39. struct timeval* 
  40. Timer::gettimeofday()
  41. {
  42.     ::gettimeofday(&t_time,0);
  43.     return &t_time;
  44. }
  45.  
  46. void
  47. Timer::print(ostream& s)
  48. {
  49.     s << form("(Timer)this= 0x%x,", this) << 
  50.          "t_starttime = " << t_starttime;
  51. }
  52.