1 #pragma once 2 3 #define CHECK_SPEED 1 4 5 #include <chrono> 6 #include <functional> 7 #include <memory> 8 #include <string> 9 #include "./Logger.h" 10 11 namespace reanimated { 12 13 class SpeedChecker { 14 public: checkSpeed(std::string tag,std::function<void ()> fun)15 static void checkSpeed(std::string tag, std::function<void()> fun) { 16 #if CHECK_SPEED 17 auto start = std::chrono::system_clock::now(); 18 #endif 19 fun(); 20 #if CHECK_SPEED 21 auto end = std::chrono::system_clock::now(); 22 std::chrono::duration<double> elapsed_seconds = end - start; 23 tag += " " + std::to_string(elapsed_seconds.count()) + "s"; 24 Logger::log(tag.c_str()); 25 #endif 26 } 27 }; 28 29 } // namespace reanimated 30