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