1 // cpu utilization timer
2 // Copyright (C) 2006, 2008 Tim Blechmann
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; see the file COPYING. If not, write to
16 // the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 // Boston, MA 02111-1307, USA.
24 #if defined(__linux__) || defined(__APPLE__) || defined(HAVE_TIMES_H)
26 #include <sys/times.h>
30 #error not implemented
43 static const double inv_clock_per_ms
= 1. / (CLOCKS_PER_SEC
* 1000);
46 ms
= (time
.tms_utime
+ time
.tms_stime
) * inv_clock_per_ms
;
48 FILETIME ignorethis
, ignorethat
;
50 bool status
= GetProcessTimes(GetCurrentProcess(), &ignorethis
, &ignorethat
,
51 &m_kerneltime
, &m_usertime
);
54 #error not implemented
61 static const double inv_clock_per_ms
= 1. / (CLOCKS_PER_SEC
* 1000);
64 double now
= (time
.tms_utime
+ time
.tms_stime
) * inv_clock_per_ms
;
67 FILETIME ignorethis
, ignorethat
;
68 FILETIME usertime
, kerneltime
;
70 bool status
= retval
= GetProcessTimes(GetCurrentProcess(), &ignorethis
, &ignorethat
,
71 &kerneltime
, &usertime
);
75 /* ignore high word */
76 double low
= ( (kerneltime
.dwLowDateTime
- m_kerneltime
.dwLowDateTime
) +
77 (usertime
.dwLowDateTime
- m_usertime
.dwLowDateTime
) ) * 0.0001;
80 #error not implemented
87 FILETIME m_kerneltime
;
92 } /* namespace nova */
94 #endif /* CPU_TIMER_HPP */