Sajat dtd es dsl kezdetleges valtozatai.
15 return double(tv.tv_sec)+double(tv.tv_usec)/1000000.0;
25 tms &getTms() {return ts;}
26 const tms &getTms() const {return ts;}
27 double getRealTime() const {return real_time;}
32 gettimeofday(&tv, 0);real_time=tv.tv_sec+double(tv.tv_usec)/1e6;
36 { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;}
38 TimeStamp(void *) { stamp();}
40 TimeStamp &operator+=(const TimeStamp &b)
42 ts.tms_utime+=b.ts.tms_utime;
43 ts.tms_stime+=b.ts.tms_stime;
44 ts.tms_cutime+=b.ts.tms_cutime;
45 ts.tms_cstime+=b.ts.tms_cstime;
46 real_time+=b.real_time;
49 TimeStamp operator+(const TimeStamp &b) const
54 TimeStamp &operator-=(const TimeStamp &b)
56 ts.tms_utime-=b.ts.tms_utime;
57 ts.tms_stime-=b.ts.tms_stime;
58 ts.tms_cutime-=b.ts.tms_cutime;
59 ts.tms_cstime-=b.ts.tms_cstime;
60 real_time-=b.real_time;
63 TimeStamp operator-(const TimeStamp &b) const
69 TimeStamp Ellapsed() const
75 friend std::ostream& operator<<(std::ostream& os,const TimeStamp &t);
77 double getUserTime() const
79 long cls = sysconf(_SC_CLK_TCK);
80 return double(ts.tms_utime)/cls;
82 double getSystemTime() const
84 long cls = sysconf(_SC_CLK_TCK);
85 return double(ts.tms_stime)/cls;
87 double getCUserTime() const
89 long cls = sysconf(_SC_CLK_TCK);
90 return double(ts.tms_cutime)/cls;
92 double getCSystemTime() const
94 long cls = sysconf(_SC_CLK_TCK);
95 return double(ts.tms_cstime)/cls;
101 TimeStamp start_time;
104 void reset() {start_time.stamp();}
107 operator TimeStamp ()
115 inline std::ostream& operator<<(std::ostream& os,const TimeStamp &t)
117 long cls = sysconf(_SC_CLK_TCK);
118 os << "u: " << double(t.getTms().tms_utime)/cls <<
119 "s, s: " << double(t.getTms().tms_stime)/cls <<
120 "s, cu: " << double(t.getTms().tms_cutime)/cls <<
121 "s, cs: " << double(t.getTms().tms_cstime)/cls <<
122 "s, real: " << t.getRealTime() << "s";
126 #endif //TIME_MEASURE_H