phonebookui/Phonebook2/Profile/src/Pbk2Profile.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Phonebook 2 profiling support.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <pbk2profile.h>
       
    20 #include <e32debug.h>
       
    21 #include <flogger.h>
       
    22 
       
    23 namespace Pbk2Profile {
       
    24 
       
    25 // --------------------------------------------------------------------------
       
    26 // TPbk2Profiling::GlobalL
       
    27 // --------------------------------------------------------------------------
       
    28 //
       
    29 EXPORT_C TPbk2Profiling* TPbk2Profiling::GlobalL()
       
    30     {
       
    31     if (!Dll::Tls())
       
    32         {
       
    33         TPbk2Profiling* profiling = new (ELeave) TPbk2Profiling;
       
    34         Dll::SetTls(profiling);
       
    35         }
       
    36     return reinterpret_cast<TPbk2Profiling*>(Dll::Tls());
       
    37     }
       
    38 
       
    39 // --------------------------------------------------------------------------
       
    40 // TPbk2Profiling::~TPbk2Profiling
       
    41 // --------------------------------------------------------------------------
       
    42 //
       
    43 EXPORT_C TPbk2Profiling::~TPbk2Profiling()
       
    44     {
       
    45     }
       
    46 
       
    47 // --------------------------------------------------------------------------
       
    48 // TPbk2Profiling::StartProfile
       
    49 // --------------------------------------------------------------------------
       
    50 //
       
    51 EXPORT_C void TPbk2Profiling::StartProfile(TInt aBin)
       
    52     {
       
    53     TTime startTime;
       
    54     startTime.HomeTime();
       
    55     iProfileArray[aBin] = startTime;
       
    56     }
       
    57 
       
    58 _LIT(KPath, "cnt");
       
    59 _LIT(KFile, "PbkProfile.txt");
       
    60 _LIT(KFormat, "Pbk Profile;%d; Time;%d;\n");
       
    61 
       
    62 // --------------------------------------------------------------------------
       
    63 // TPbk2Profiling::EndProfile
       
    64 // --------------------------------------------------------------------------
       
    65 //
       
    66 EXPORT_C void TPbk2Profiling::EndProfile(TInt aBin) const
       
    67     {
       
    68     TTime endTime;
       
    69     endTime.HomeTime();
       
    70 
       
    71     TInt duration = (TInt) endTime.MicroSecondsFrom(iProfileArray[aBin]).Int64();
       
    72     RFileLogger::WriteFormat(KPath, KFile, EFileLoggingModeAppend, KFormat, aBin, duration);
       
    73 
       
    74 	//RDebug::Print(_L("Pbk Profile;%d; Time;%d;\n"),
       
    75     //    aBin, endTime.MicroSecondsFrom(iProfileArray[aBin]));
       
    76     }
       
    77 
       
    78 // --------------------------------------------------------------------------
       
    79 // TPbk2Profiling::TPbk2Profiling
       
    80 // --------------------------------------------------------------------------
       
    81 //
       
    82 EXPORT_C TPbk2Profiling::TPbk2Profiling()
       
    83     {
       
    84     }
       
    85 
       
    86 }  // namespace Pbk2Profile
       
    87 
       
    88 // End of File