Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #pragma once
  2.  
  3. namespace Maxx {
  4. namespace Utils {
  5.  
  6. //--------------------------------------------------------------------
  7. class ProfileScope
  8. {
  9. public:
  10.   //--------------------------------------------------------------------
  11.   ProfileScope(const std::string& description)
  12.     : startTime(SDL_GetTicks())
  13.     , description(description)
  14.   {
  15.   }
  16.   //--------------------------------------------------------------------
  17.   ~ProfileScope()
  18.   {
  19.     Uint32 elapsedTime = SDL_GetTicks() - startTime;
  20.     printf("PROFILE %d ms\t%s\n", elapsedTime, description.c_str());
  21.   }
  22.   //--------------------------------------------------------------------  
  23. private:
  24.   Uint32 startTime;
  25.   std::string description;
  26. };
  27.  
  28. } // Utils
  29. } // Maxx
  30.  
  31. //--------------------------------------------------------------------
  32. #if defined(PROFILER_ON)
  33. #define PROFILE_SCOPE(str) Maxx::Utils::ProfileScope profileScoper(str);
  34. #undef PROFILER_ON
  35. #else
  36. #define PROFILE_SCOPE(str)
  37. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement