2 cpu-timer.cc -- implement Cpu_timer
4 source file of the Flower Library
6 (c) 1997--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "cpu-timer.hh"
13 #ifndef CLOCKS_PER_SEC
15 #define CLOCKS_PER_SEC CLK_TCK
16 #elif defined _SC_CLK_TCK
17 #define CLOCKS_PER_SEC sysconf (_SC_CLK_TCK)
19 #error cannot determine CLOCKS_PER_SEC
23 Cpu_timer::Cpu_timer ()
30 start_clock_
= clock ();
36 clock_t stop
= clock ();
37 return (stop
- start_clock_
) / Real (CLOCKS_PER_SEC
);