odin-blend2d

Odin bindings to Blend2D
Log | Files | Refs | README | LICENSE

performancetimer.h (795B)


      1 // This file is part of AsmJit project <https://asmjit.com>
      2 //
      3 // See <asmjit/core.h> or LICENSE.md for license and copyright information
      4 // SPDX-License-Identifier: Zlib
      5 
      6 #ifndef PERFORMANCETIMER_H_INCLUDED
      7 #define PERFORMANCETIMER_H_INCLUDED
      8 
      9 #include <asmjit/core.h>
     10 #include <chrono>
     11 
     12 class PerformanceTimer {
     13 public:
     14   using TimePoint = std::chrono::high_resolution_clock::time_point;
     15 
     16   TimePoint _start_time {};
     17   TimePoint _end_time {};
     18 
     19   inline void start() { _start_time = std::chrono::high_resolution_clock::now(); }
     20   inline void stop() { _end_time = std::chrono::high_resolution_clock::now(); }
     21 
     22   inline double duration() const {
     23     std::chrono::duration<double> elapsed = _end_time - _start_time;
     24     return elapsed.count() * 1000;
     25   }
     26 };
     27 
     28 #endif // PERFORMANCETIMER_H_INCLUDED