1 /*
2 * vim: ts=4 sw=4 et tw=0 wm=0
3 *
4 * libavoid - Fast, Incremental, Object-avoiding Line Router
5 *
6 * Copyright (C) 2004-2008 Monash University
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 * See the file LICENSE.LGPL distributed with the library.
13 *
14 * Licensees holding a valid commercial license may use this file in
15 * accordance with the commercial license agreement provided with the
16 * library.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 *
22 * Author(s): Michael Wybrow <mjwybrow@users.sourceforge.net>
23 */
26 #ifndef PROFILE_H
27 #define PROFILE_H
29 #include <ctime>
31 namespace Avoid {
34 #ifdef NOTIMERS
36 #define register_timer(t) do {} while(0)
37 #define regstart_timer(t) do {} while(0)
38 #define start_timer() do {} while(0)
39 #define stop_timer() do {} while(0)
41 #else
43 #define register_timer(t) router->timers.Register(t)
44 #define regstart_timer(t) router->timers.Register(t, timerStart)
45 #define start_timer() router->timers.Start()
46 #define stop_timer() router->timers.Stop()
48 #endif
50 typedef unsigned long long int bigclock_t;
52 enum TimerIndex
53 {
54 tmNon = 0,
55 tmAdd,
56 tmDel,
57 tmMov,
58 tmPth,
59 tmSev,
60 tmOrthogGraph,
61 tmOrthogRoute,
62 tmOrthogCentre,
63 tmOrthogNudge,
64 tmCount
65 };
68 static const bool timerStart = true;
69 static const bool timerDelay = false;
72 class Timer
73 {
74 public:
75 Timer();
76 void Register(const TimerIndex t, const bool start = timerDelay);
77 void Start(void);
78 void Stop(void);
79 void Reset(void);
80 void Print(TimerIndex, FILE *fp);
81 void PrintAll(FILE *fp);
83 private:
84 clock_t cStart[tmCount];
85 bigclock_t cTotal[tmCount];
86 bigclock_t cPath[tmCount];
87 int cTally[tmCount];
88 int cPathTally[tmCount];
89 clock_t cMax[tmCount];
90 clock_t cPathMax[tmCount];
92 bool running;
93 long count;
94 TimerIndex type, lasttype;
95 };
98 }
100 #endif