b2Timer.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2011 Erin Catto http://box2d.org
  3. * Copyright (c) 2014 Google, Inc.
  4. *
  5. * This software is provided 'as-is', without any express or implied
  6. * warranty. In no event will the authors be held liable for any damages
  7. * arising from the use of this software.
  8. * Permission is granted to anyone to use this software for any purpose,
  9. * including commercial applications, and to alter it and redistribute it
  10. * freely, subject to the following restrictions:
  11. * 1. The origin of this software must not be misrepresented; you must not
  12. * claim that you wrote the original software. If you use this software
  13. * in a product, an acknowledgment in the product documentation would be
  14. * appreciated but is not required.
  15. * 2. Altered source versions must be plainly marked as such, and must not be
  16. * misrepresented as being the original software.
  17. * 3. This notice may not be removed or altered from any source distribution.
  18. */
  19. #ifndef B2_TIMER_H
  20. #define B2_TIMER_H
  21. #include <Box2D/Common/b2Settings.h>
  22. /// Timer for profiling. This has platform specific code and may
  23. /// not work on every platform.
  24. class b2Timer
  25. {
  26. public:
  27. /// Constructor
  28. b2Timer();
  29. /// Reset the timer.
  30. void Reset();
  31. /// Get the time since construction or the last reset.
  32. float32 GetMilliseconds() const;
  33. private:
  34. /// Get platform specific tick count
  35. static int64 GetTicks();
  36. #if defined(_WIN32)
  37. static float64 s_invFrequency;
  38. #endif
  39. int64 m_start;
  40. };
  41. #endif