00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <time.h>
00032 #include <stdlib.h>
00033 #include "StMuTimer.h"
00034
00035 ClassImp(StMuTimer)
00036
00037 StMuTimer::StMuTimer() : mStartTime(0), mStopTime(0), mIsStopped(1)
00038 {}
00039
00040 double StMuTimer::resolution() const
00041 {
00042 return 1./double(CLOCKS_PER_SEC);
00043 }
00044
00045 double StMuTimer::elapsedTime() const
00046 {
00047 return (mIsStopped ? mStopTime : absoluteTime()) - mStartTime;
00048 }
00049
00050 void StMuTimer::reset()
00051 {
00052 mStartTime = 0;
00053 mStopTime = 0;
00054 mIsStopped = 1;
00055 }
00056
00057 void StMuTimer::start()
00058 {
00059 mStartTime = absoluteTime() - elapsedTime();
00060 mIsStopped = 0;
00061 }
00062
00063 void StMuTimer::stop()
00064 {
00065 mStopTime = absoluteTime();
00066 mIsStopped = 1;
00067 }
00068
00069
00070 double StMuTimer::absoluteTime()
00071 {
00072 return (double)clock()/CLOCKS_PER_SEC;
00073 }
00074