1 /*---------------------------------------------------------------------------* 2 Project: Horizon 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: 25674 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NN_FONT_FONT_STOPWATCH_H_ 17 #define NN_FONT_FONT_STOPWATCH_H_ 18 19 #ifdef NN_PLATFORM_CTR 20 // #define NN_FONT_PROFILE 1 21 #endif 22 23 #if defined(NN_FONT_PROFILE) 24 #include <nn/os.h> 25 26 namespace nn { 27 namespace font { 28 29 class Stopwatch 30 { 31 public: Start()32 void Start() 33 { 34 NN_ASSERT(! IsRunning()); 35 36 using namespace nn::os; 37 m_StartTick = Tick::GetSystemCurrent(); 38 } 39 Stop()40 void Stop() 41 { 42 NN_ASSERT(IsRunning()); 43 44 using namespace nn::os; 45 using namespace nn::fnd; 46 47 m_TotalTick += Tick::GetSystemCurrent() - m_StartTick; 48 m_StartTick = nn::os::Tick(); 49 } 50 Reset()51 void Reset() 52 { 53 m_TotalTick = nn::os::Tick(); 54 } 55 GetElapsedTime()56 nn::fnd::TimeSpan GetElapsedTime() const 57 { 58 return m_TotalTick; 59 } 60 IsRunning()61 bool IsRunning() const 62 { 63 return m_StartTick != nn::os::Tick(); 64 } 65 66 private: 67 nn::os::Tick m_StartTick; 68 nn::os::Tick m_TotalTick; 69 }; 70 71 } // namespace font 72 } // namespace nn 73 74 #define NN_FONT_STOPWATCH_START(sw) (sw).Start() 75 76 #define NN_FONT_STOPWATCH_STOP(sw) (sw).Stop() 77 78 #define NN_FONT_COUNTUP(counter) (++(counter)) 79 #else 80 #define NN_FONT_STOPWATCH_START(sw) ((void)0) 81 82 #define NN_FONT_STOPWATCH_STOP(sw) ((void)0) 83 84 #define NN_FONT_COUNTUP(counter) ((void)0) 85 #endif 86 87 #endif // NN_FONT_FONT_STOPWATCH_H_ 88