1 // -*- C++ -*-
2 //==============================================================================================
3 //
4 //	This file is part of LiDIA --- a library for computational number theory
5 //
6 //	Copyright (c) 1994--2001 the LiDIA Group.  All rights reserved.
7 //
8 //	See http://www.informatik.tu-darmstadt.de/TI/LiDIA/
9 //
10 //----------------------------------------------------------------------------------------------
11 //
12 //	$Id$
13 //
14 //	Author	: Thomas Papanikolaou (TP)
15 //	Changes	: See CVS log
16 //
17 //==============================================================================================
18 
19 
20 #ifndef LIDIA_TIMER_H_GUARD_
21 #define LIDIA_TIMER_H_GUARD_
22 
23 
24 
25 #ifndef LIDIA_LIDIA_H_GUARD_
26 # include	"LiDIA/LiDIA.h"
27 #endif
28 
29 
30 
31 #ifdef LIDIA_NAMESPACE
32 namespace LiDIA {
33 # define IN_NAMESPACE_LIDIA
34 #endif
35 
36 
37 
38 enum {
39 	TIME_MODE,
40 	HMS_MODE
41 };
42 
43 
44 
45 class timer {
46 private:
47 
48   static const double GRANULARITY;
49 
50   static long _clk_tcks;
51 
52   long user_t, sys_t;
53   long t_user_t, t_sys_t;
54   int print_mode;
55 
56   void print_hms(std::ostream & out = std::cout, long rt = 0) const;
57 
58 public:
59 
60 
61 	static long clk_tcks ();
62 
63 	timer();
64 	timer(const timer &);
65 	~timer();
66 
67 	int set_print_mode(int x = 1);
68 	int get_print_mode() const;
69 
70 	void start_timer();
71 	void stop_timer();
72 	void cont_timer();
73 
74 	long user_time() const;
75 	long sys_time() const;
76 	long real_time() const;
77 
78 	void print(std::ostream & out = std::cout) const;
79 
80 	timer & operator = (const timer & t);
81 
82         timer & operator + (const timer &);
83         timer & operator - (const timer &);
84         timer & operator / (double);
85 
86 	friend std::ostream & operator << (std::ostream & out, const timer & t);
87 
88 };
89 
90 
91 
92 #ifdef LIDIA_NAMESPACE
93 }	// end of namespace LiDIA
94 # undef IN_NAMESPACE_LIDIA
95 #endif
96 
97 
98 
99 #endif	// LIDIA_TIMER_H_GUARD_
100