87
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef CACLIENTTEST_GLOBAL_H
|
|
19 |
#define CACLIENTTEST_GLOBAL_H
|
|
20 |
|
|
21 |
#include <QDebug>
|
|
22 |
#include <QtGlobal>
|
|
23 |
|
|
24 |
/*!
|
|
25 |
To enable logging of function entry and exit use the following flag for qmake:
|
|
26 |
-config nft
|
|
27 |
To include in logs extra information about RAM and heap usage, define an additional constant e.g. in ProductVariant.hrh:
|
|
28 |
#define NFT_RAM
|
|
29 |
*/
|
|
30 |
|
|
31 |
#ifdef NFT
|
|
32 |
#ifdef Q_OS_SYMBIAN
|
|
33 |
#include <hal.h>
|
|
34 |
#include <e32std.h>
|
|
35 |
#endif
|
|
36 |
#endif
|
|
37 |
|
|
38 |
#ifdef NFT
|
|
39 |
|
|
40 |
#define CACLIENTTEST(aText) qDebug() << QString(aText)
|
|
41 |
|
|
42 |
#ifdef Q_OS_SYMBIAN
|
|
43 |
#ifdef NFT_RAM
|
|
44 |
#define CACLIENTTEST_FREERAM_ENTRY(function) \
|
|
45 |
TInt CACLIENTTEST_ENTRY_RAM(0); \
|
|
46 |
TInt CACLIENTTEST_ENTRY_HEAP(0); \
|
|
47 |
TInt CACLIENTTEST_ENTRY_HEAP_SIZE(0); \
|
|
48 |
{ \
|
|
49 |
TInt allRAM(0); \
|
|
50 |
HAL::Get(HAL::EMemoryRAM, allRAM); \
|
|
51 |
HAL::Get(HAL::EMemoryRAMFree, CACLIENTTEST_ENTRY_RAM); \
|
|
52 |
RHeap &heap = User::Heap(); \
|
|
53 |
TInt biggestBlock(0); \
|
|
54 |
CACLIENTTEST_ENTRY_HEAP = heap.Available(biggestBlock); \
|
|
55 |
CACLIENTTEST_ENTRY_HEAP_SIZE = heap.Size(); \
|
|
56 |
qDebug("(nft) " function " - Memory (kB) - Free RAM: %d, Heap size: %d, Free heap: %d", \
|
|
57 |
CACLIENTTEST_ENTRY_RAM >> 10, CACLIENTTEST_ENTRY_HEAP_SIZE >> 10, \
|
|
58 |
CACLIENTTEST_ENTRY_HEAP >> 10); \
|
|
59 |
}
|
|
60 |
|
|
61 |
#define CACLIENTTEST_FREERAM_EXIT(function) \
|
|
62 |
{ \
|
|
63 |
TInt allRAM(0); \
|
|
64 |
TInt freeRAM(0); \
|
|
65 |
HAL::Get(HAL::EMemoryRAM, allRAM); \
|
|
66 |
HAL::Get(HAL::EMemoryRAMFree, freeRAM); \
|
|
67 |
RHeap &heap = User::Heap(); \
|
|
68 |
TInt biggestBlock(0); \
|
|
69 |
TInt heapFree = heap.Available(biggestBlock); \
|
|
70 |
TInt heapSize = heap.Size(); \
|
|
71 |
qDebug("(nft) " function " - Memory (kB) - Free RAM: %d, Heap size: %d, Free heap: %d", \
|
|
72 |
freeRAM >> 10, heapSize >> 10, heapFree >> 10); \
|
|
73 |
qDebug("(nft) " function " - Memory (kB) - RAM diff: %d, Heap size diff: %d, Free heap diff: %d", \
|
|
74 |
(freeRAM-CACLIENTTEST_ENTRY_RAM) >> 10, (heapSize-CACLIENTTEST_ENTRY_HEAP_SIZE) >> 10, \
|
|
75 |
(heapFree-CACLIENTTEST_ENTRY_HEAP) >> 10); \
|
|
76 |
}
|
|
77 |
|
|
78 |
#else
|
|
79 |
|
|
80 |
#define CACLIENTTEST_FREERAM_ENTRY(function)
|
|
81 |
#define CACLIENTTEST_FREERAM_EXIT(function)
|
|
82 |
|
|
83 |
#endif
|
|
84 |
|
|
85 |
#define CACLIENTTESTTIME_ENTRY(function) \
|
|
86 |
TInt64 CACLIENTTEST_ENTRY_TIME(0); \
|
|
87 |
{ \
|
|
88 |
TTime t; \
|
|
89 |
t.UniversalTime(); \
|
|
90 |
qDebug("\n" function " entry:%20lld", t.Int64()); \
|
|
91 |
CACLIENTTEST_ENTRY_TIME = t.Int64(); \
|
|
92 |
}
|
|
93 |
|
|
94 |
#define CACLIENTTESTTIME_EXIT(function) { \
|
|
95 |
TTime t; \
|
|
96 |
t.UniversalTime(); \
|
|
97 |
qDebug("\n" function " entry:%20lld\n" function " difference:%20lld", t.Int64(), \
|
|
98 |
t.Int64()-CACLIENTTEST_ENTRY_TIME); \
|
|
99 |
}
|
|
100 |
|
|
101 |
#define CACLIENTTEST_FUNC_ENTRY(function) CACLIENTTEST_FREERAM_ENTRY(function) \
|
|
102 |
CACLIENTTESTTIME_ENTRY(function)
|
|
103 |
#define CACLIENTTEST_FUNC_EXIT(function) CACLIENTTESTTIME_EXIT(function) \
|
|
104 |
CACLIENTTEST_FREERAM_EXIT(function)
|
|
105 |
|
|
106 |
#else //Q_OS_SYMBIAN
|
|
107 |
#define CACLIENTTEST_FUNC_ENTRY(function) qDebug()<< function << " entry";
|
|
108 |
#define CACLIENTTEST_FUNC_EXIT(function) qDebug()<< function << " exit";
|
|
109 |
#endif //Q_OS_SYMBIAN
|
|
110 |
#else //NFT
|
|
111 |
#define CACLIENTTEST_FUNC_ENTRY(function)
|
|
112 |
#define CACLIENTTEST_FUNC_EXIT(function)
|
|
113 |
#endif //NFT
|
|
114 |
|
|
115 |
#endif //CACLIENTTEST_GLOBAL_H
|