871.4.3
by Neil Jagdish Patel
Some speed improvements and a simple tool for doing time calculations when your trying to do performance improvements |
1 |
/*
|
2 |
* Copyright (C) 2010 Canonical Ltd
|
|
3 |
*
|
|
4 |
* This program is free software: you can redistribute it and/or modify
|
|
5 |
* it under the terms of the GNU General Public License version 3 as
|
|
6 |
* published by the Free Software Foundation.
|
|
7 |
*
|
|
8 |
* This program is distributed in the hope that it will be useful,
|
|
9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
* GNU General Public License for more details.
|
|
12 |
*
|
|
13 |
* You should have received a copy of the GNU General Public License
|
|
14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15 |
*
|
|
16 |
* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
|
|
17 |
*/
|
|
18 |
||
19 |
#ifndef _TIME_ME_H_
|
|
20 |
#define _TIME_ME_H_
|
|
21 |
||
22 |
#include <glib.h> |
|
23 |
||
24 |
extern gint64 _____last_time_____; |
|
25 |
extern gint64 _____start_time_____; |
|
26 |
||
27 |
#define TIME_ME_START(foo) { _____last_time_____ = g_get_monotonic_time (); _____start_time_____ = _____last_time_____; g_print ("\nSTARTED (%s)\n", foo);}
|
|
28 |
||
29 |
#define TIME_ME_LOG(foo) { \
|
|
30 |
gint64 ____now_time___ = g_get_monotonic_time (); \
|
|
31 |
g_print ("%f: %s\n", (____now_time___ - _____last_time_____)/1000.0f, foo); \
|
|
32 |
_____last_time_____ = ____now_time___; \
|
|
33 |
}
|
|
34 |
||
35 |
#define TIME_ME_FINSH(foo) { \
|
|
36 |
gint64 ____now_time___ = g_get_monotonic_time (); \
|
|
37 |
g_print ("\n%f: FINISHED (%s)\n", (____now_time___ - _____start_time_____)/1000.0f, foo); \
|
|
38 |
}
|
|
39 |
||
40 |
#define TIME_ME_FUNC() {_____last_time_____ = g_get_monotonic_time (); _____start_time_____ = _____last_time_____;}
|
|
41 |
#define TIME_ME_ENDFUNC() TIME_ME_FINSH(G_STRFUNC)
|
|
42 |
||
43 |
#endif //_TIME_ME_H_ |