screensaver/inc/snsrtest_global.h
changeset 62 341166945d65
equal deleted inserted replaced
57:2e2dc3d30ca8 62:341166945d65
       
     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: Global Screensaver macros for testing purposes.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef SNSRTEST_GLOBAL_H
       
    19 #define SNSRTEST_GLOBAL_H
       
    20 
       
    21 #ifndef SCREENSAVER_TEST
       
    22     #define SCREENSAVER_TEST_CLASS(aClassName)
       
    23     #define SCREENSAVER_TEST_FRIEND_CLASS(aClassName)
       
    24 #else
       
    25     #define SCREENSAVER_TEST_CLASS(aClassName) class aClassName;
       
    26     #define SCREENSAVER_TEST_FRIEND_CLASS(aClassName) friend class aClassName;
       
    27 #endif //SCREENSAVER_TEST
       
    28 
       
    29 /*!    
       
    30 To enable logging of function entry and exit use the following flag for qmake:
       
    31 -config nft
       
    32 To enable logging of function entry and exit aswell as RAM usage (Symbian only!)
       
    33 use the following flag for qmake:
       
    34 -config nft_ram
       
    35 */
       
    36 
       
    37 #ifdef NFT
       
    38     #include <QDebug>
       
    39     #include <QTime>
       
    40 
       
    41 #ifdef NFT_RAM && Q_OS_SYMBIAN
       
    42     #include <hal.h>
       
    43     #include <e32std.h>
       
    44 
       
    45     #define SCREENSAVER_TEST_FREERAM_ENTRY(function) \
       
    46     TInt gEntryFreeRam(0); \
       
    47     TInt gEntryFreeHeap(0); \
       
    48     TInt gEntryTotalHeap(0); \
       
    49     { \
       
    50         HAL::Get(HAL::EMemoryRAMFree, gEntryFreeRam); \
       
    51         RHeap &heap = User::Heap(); \
       
    52         TInt biggestBlock(0); \
       
    53         gEntryFreeHeap = heap.Available(biggestBlock); \
       
    54         gEntryTotalHeap = heap.Size(); \
       
    55         qDebug("(snsr nft RAM in) " function \
       
    56             " - Memory (kB) - Free RAM: %d, Heap size: %d, Free heap: %d", \
       
    57             gEntryFreeRam >> 10, \
       
    58             gEntryTotalHeap >> 10, \
       
    59             gEntryFreeHeap >> 10); \
       
    60     }
       
    61     
       
    62     #define SCREENSAVER_TEST_FREERAM_EXIT(function) \
       
    63     { \
       
    64         TInt freeRAM(0); \
       
    65         HAL::Get(HAL::EMemoryRAMFree, freeRAM); \
       
    66         RHeap &heap = User::Heap(); \
       
    67         TInt biggestBlock(0); \
       
    68         TInt freeHeap = heap.Available(biggestBlock); \
       
    69         TInt totalHeap = heap.Size(); \
       
    70         qDebug("(snsr nft RAM out) " function \
       
    71             " - Memory (kB) - Free RAM: %d (%+d), Heap size: %d (%+d), Free heap: %d (%+d)", \
       
    72             freeRAM >> 10, (freeRAM-gEntryFreeRam) >> 10, \
       
    73             totalHeap >> 10, (totalHeap-gEntryTotalHeap) >> 10, \
       
    74             freeHeap >> 10, (freeHeap-gEntryFreeHeap) >> 10); \
       
    75     }
       
    76 #else // NFT_RAM && Q_OS_SYMBIAN
       
    77     #define SCREENSAVER_TEST_FREERAM_ENTRY(function)
       
    78     #define SCREENSAVER_TEST_FREERAM_EXIT(function)
       
    79 #endif // NFT_RAM && Q_OS_SYMBIAN
       
    80 
       
    81     #define SCREENSAVER_TEST_TIME_ENTRY(function) \
       
    82     QTime _ENTRY_TIME; \
       
    83     _ENTRY_TIME.start(); \
       
    84     { \
       
    85         qDebug() << "(snsr nft time in)" << function << "-" << \
       
    86             _ENTRY_TIME.toString("hh:mm:ss.zzz"); \
       
    87     }
       
    88         
       
    89     #define SCREENSAVER_TEST_TIME_EXIT(function) \
       
    90     { \
       
    91         qDebug() << "(snsr nft time out)" << function << "-" << \
       
    92             QTime::currentTime().toString("hh:mm:ss.zzz") << \
       
    93             "elapsed:" << _ENTRY_TIME.elapsed() << "ms"; \
       
    94     }
       
    95 
       
    96     #define SCREENSAVER_TEST_FUNC_ENTRY(function)   SCREENSAVER_TEST_TIME_ENTRY(function) \
       
    97         SCREENSAVER_TEST_FREERAM_ENTRY(function)
       
    98     #define SCREENSAVER_TEST_FUNC_EXIT(function)    SCREENSAVER_TEST_TIME_EXIT(function) \
       
    99         SCREENSAVER_TEST_FREERAM_EXIT(function)
       
   100 #else //NFT
       
   101     #define SCREENSAVER_TEST_FUNC_ENTRY(function)
       
   102     #define SCREENSAVER_TEST_FUNC_EXIT(function)
       
   103 #endif //NFT
       
   104 
       
   105 #endif // SNSRTEST_GLOBAL_H