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