testing
[gnucap-felix.git] / src / l_timer.h
blobb3500919483ef7ce92eb24532b337a65d7fa11e3
1 /*$Id: l_timer.h,v 1.1 2009-10-23 12:01:45 felix Exp $ -*- C++ -*-
2 * Copyright (C) 2001 Albert Davis
3 * Author: Albert Davis <aldavis@gnu.org>
5 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *------------------------------------------------------------------
22 * CPU time accounting
24 //testing=script 2006.07.13
25 #ifndef L_TIMER_H
26 #define L_TIMER_H
27 #include "io_.h"
28 /*--------------------------------------------------------------------------*/
29 class OMSTREAM;
30 /*--------------------------------------------------------------------------*/
31 class INTERFACE TIMER {
32 private:
33 double _ref; // time the clock was started
34 double _last; // time of timed operation
35 double _total; // time since program start
36 bool _running;
37 std::string _name;
38 public:
39 explicit TIMER();
40 explicit TIMER(const std::string&);
41 ~TIMER() {}
42 TIMER& fullreset();
43 TIMER& reset();
44 TIMER& start();
45 TIMER& stop();
46 TIMER& check();
47 double elapsed()const {return _last;}
48 bool is_running()const {return _running;}
50 TIMER& print(OMSTREAM& s = IO::mstdout);
51 TIMER& operator=(const TIMER&);
52 friend INTERFACE TIMER operator-(const TIMER&,const TIMER&);
54 template <class T>
55 T& operator<<(T & s, TIMER & t) {t.print(s); return s;}
56 /*--------------------------------------------------------------------------*/
57 /*--------------------------------------------------------------------------*/
58 #endif
59 // vim:ts=8:sw=2:noet: