1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: font_Stopwatch.h 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Revision: 13145 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_FONT_STOPWATCH_H_ 17 #define NW_FONT_STOPWATCH_H_ 18 19 #if defined(_MSC_VER) && _MSC_VER >= 1500 20 #pragma once 21 #endif 22 23 #ifdef NW_PLATFORM_CTR 24 // #define NW_FONT_PROFILE 1 25 #endif 26 27 #if defined(NW_FONT_PROFILE) 28 #include <nn/os.h> 29 30 namespace nw { 31 namespace font { 32 33 class Stopwatch 34 { 35 public: Start()36 void Start() 37 { 38 NN_ASSERT(! IsRunning()); 39 40 using namespace nn::os; 41 m_StartTick = Tick::GetSystemCurrent(); 42 } 43 Stop()44 void Stop() 45 { 46 NN_ASSERT(IsRunning()); 47 48 using namespace nn::os; 49 using namespace nn::fnd; 50 51 m_TotalTick += Tick::GetSystemCurrent() - m_StartTick; 52 m_StartTick = nn::os::Tick(); 53 } 54 Reset()55 void Reset() 56 { 57 m_TotalTick = nn::os::Tick(); 58 } 59 GetElapsedTime()60 nn::fnd::TimeSpan GetElapsedTime() const 61 { 62 return m_TotalTick; 63 } 64 IsRunning()65 bool IsRunning() const 66 { 67 return m_StartTick != nn::os::Tick(); 68 } 69 70 private: 71 nn::os::Tick m_StartTick; 72 nn::os::Tick m_TotalTick; 73 }; 74 75 } // namespace font 76 } // namespace nw 77 78 #define NW_FONT_STOPWATCH_START(sw) (sw).Start() 79 80 #define NW_FONT_STOPWATCH_STOP(sw) (sw).Stop() 81 82 #define NW_FONT_COUNTUP(counter) (++(counter)) 83 #else 84 #define NW_FONT_STOPWATCH_START(sw) ((void)0) 85 86 #define NW_FONT_STOPWATCH_STOP(sw) ((void)0) 87 88 #define NW_FONT_COUNTUP(counter) ((void)0) 89 #endif 90 91 #endif // NW_FONT_STOPWATCH_H_ 92