release commit
[lilypond.git] / flower / cpu-timer.cc
blob832606b7018f9ae4416a1d321fa8511fc65e8588
1 /*
2 cpu-timer.cc -- implement Cpu_timer
4 source file of the Flower Library
6 (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "cpu-timer.hh"
11 #include <unistd.h>
12 // nextstep
13 #ifndef CLOCKS_PER_SEC
14 #ifdef CLK_TCK
15 #define CLOCKS_PER_SEC CLK_TCK
16 #elif defined _SC_CLK_TCK
17 #define CLOCKS_PER_SEC sysconf (_SC_CLK_TCK)
18 #else
19 #error cannot determine CLOCKS_PER_SEC
20 #endif
21 #endif
23 Cpu_timer::Cpu_timer ()
25 restart ();
27 void
28 Cpu_timer::restart ()
30 start_clock_ = clock ();
33 Real
34 Cpu_timer::read ()
36 clock_t stop = clock ();
37 return (stop - start_clock_) / Real (CLOCKS_PER_SEC);