utils.cpp 371 B

123456789101112131415161718192021
  1. #include "utils.hpp"
  2. #include <iostream>
  3. using namespace std::chrono_literals;
  4. frametime_logger::frametime_logger(size_t limit) : accum{}, count{}, limit{limit}
  5. {}
  6. void frametime_logger::log(clock::duration frametime)
  7. {
  8. accum += frametime;
  9. ++count;
  10. if(count == limit)
  11. {
  12. auto avg = accum/count;
  13. std::cout << avg.count() << '\n';
  14. count = 0;
  15. accum = 0s;
  16. }
  17. }