Measure avg frame-time per sec
This commit is contained in:
@@ -1,18 +1,40 @@
|
||||
#include <PSX/Timer/high_res_timer.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
#pragma GCC warning "Enable this code to verify that high percision counter is still functional"
|
||||
extern "C" void busy_loop(int count);
|
||||
namespace Overlay {
|
||||
void mesaure_busy_loop() {
|
||||
static constexpr auto Counts = 500;
|
||||
|
||||
JabyEngine::HighResTime::enable();
|
||||
const auto start = JabyEngine::HighResTime::get_time_stamp();
|
||||
busy_loop(Counts);
|
||||
const auto end = JabyEngine::HighResTime::get_time_stamp();
|
||||
JabyEngine::HighResTime::disable();
|
||||
|
||||
printf("Busy loop of %i took %ims %ins\n", Counts, start.milliseconds_to(end), start.microseconds_to(end));
|
||||
}
|
||||
#include "../Overlay.hpp"
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" void busy_loop(int count);
|
||||
|
||||
namespace Overlay {
|
||||
namespace TimerTest {
|
||||
static size_t avg = 0;
|
||||
static size_t cur_rounds = 0;
|
||||
|
||||
void mesaure_busy_loop() {
|
||||
static constexpr auto Counts = 500;
|
||||
|
||||
JabyEngine::HighResTime::enable();
|
||||
const auto start = JabyEngine::HighResTime::get_time_stamp();
|
||||
busy_loop(Counts);
|
||||
const auto end = JabyEngine::HighResTime::get_time_stamp();
|
||||
JabyEngine::HighResTime::disable();
|
||||
|
||||
printf("Busy loop of %i took %ims %ins\n", Counts, start.milliseconds_to(end), start.microseconds_to(end));
|
||||
}
|
||||
|
||||
TimeStamp start_measuring() {
|
||||
return JabyEngine::HighResTime::get_time_stamp();
|
||||
}
|
||||
|
||||
void end_measuring(const TimeStamp& start, size_t data_samples) {
|
||||
const auto end = JabyEngine::HighResTime::get_time_stamp();
|
||||
|
||||
avg += start.microseconds_to(end);
|
||||
cur_rounds++;
|
||||
if(cur_rounds == data_samples) {
|
||||
printf("AVG Time: %ius\n", avg/cur_rounds);
|
||||
|
||||
avg = 0;
|
||||
cur_rounds = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user