summaryrefslogtreecommitdiff
path: root/library/qpedebug.cpp
Unidiff
Diffstat (limited to 'library/qpedebug.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpedebug.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/library/qpedebug.cpp b/library/qpedebug.cpp
new file mode 100644
index 0000000..29bcbb6
--- a/dev/null
+++ b/library/qpedebug.cpp
@@ -0,0 +1,51 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include "qpedebug.h"
22#include <stdio.h>
23#include <sys/time.h>
24#include <unistd.h>
25
26struct timeval qpe_debuglast;
27
28void qpe_debugTime( const char *file, int line, const char *desc )
29{
30 struct timeval tv;
31 gettimeofday( &tv, 0 );
32
33 int tdiff = tv.tv_usec - qpe_debuglast.tv_usec;
34 tdiff += (tv.tv_sec - qpe_debuglast.tv_sec) * 1000000;
35
36 fprintf( stderr, "%s:%d Time: %ld.%06ld", file, line, tv.tv_sec, tv.tv_usec);
37
38 static int pid = getpid();
39
40 if ( qpe_debuglast.tv_sec )
41 fprintf( stderr, " (pid %d delta %dus)", pid, tdiff );
42
43 if ( desc )
44 fprintf( stderr, " (%s)", desc );
45
46 fprintf( stderr, "\n" );
47
48 qpe_debuglast = tv;
49}
50
51