1 /*
2 * vim: ts=4 sw=4 et tw=0 wm=0
3 *
4 * libavoid - Fast, Incremental, Object-avoiding Line Router
5 * Copyright (C) 2004-2006 Michael Wybrow <mjwybrow@users.sourceforge.net>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library 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 GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
23 #ifndef PROFILE_H
24 #define PROFILE_H
26 #include <ctime>
28 namespace Avoid {
31 #ifdef NOTIMERS
33 #define register_timer(t) do {} while(0)
34 #define regstart_timer(t) do {} while(0)
35 #define start_timer() do {} while(0)
36 #define stop_timer() do {} while(0)
38 #else
40 #define register_timer(t) router->timers.Register(t)
41 #define regstart_timer(t) router->timers.Register(t, timerStart)
42 #define start_timer() router->timers.Start()
43 #define stop_timer() router->timers.Stop()
45 #endif
47 typedef unsigned long long int bigclock_t;
49 static const int tmCount = 5;
51 static const int tmNon = -1;
52 static const int tmAdd = 0;
53 static const int tmDel = 1;
54 static const int tmMov = 2;
55 static const int tmPth = 3;
56 static const int tmSev = 4;
59 static const bool timerStart = true;
60 static const bool timerDelay = false;
63 class Timer
64 {
65 public:
66 Timer();
67 void Register(const int t, const bool start = timerDelay);
68 void Start(void);
69 void Stop(void);
70 void Reset(void);
71 void Print(const int t);
72 void PrintAll(void);
74 private:
75 clock_t cStart[tmCount];
76 bigclock_t cTotal[tmCount];
77 bigclock_t cPath[tmCount];
78 int cTally[tmCount];
79 int cPathTally[tmCount];
80 clock_t cMax[tmCount];
81 clock_t cPathMax[tmCount];
83 bool running;
84 long count;
85 int type, lasttype;
86 };
89 }
91 #endif