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