Instrumentation on the cycle/update/render performance. So far looks like update and then render are the worst.

master
Zed A. Shaw 16 hours ago
parent 407cc58f1f
commit 2fc7fbb788
  1. 4
      src/chip8.cpp
  2. 13
      src/main.cpp

@ -94,8 +94,10 @@ void Chip8::Cycle() {
// Increment the PC before we execute anything
pc += 2;
auto func_ptr = table[(opcode & 0xF000u) >> 12u];
// decode and Execute
((*this).*(table[(opcode & 0xF000u) >> 12u]))();
(this->*(func_ptr))();
// Decrement the delay timer if it's been set
if(delayTimer > 0) {

@ -94,6 +94,7 @@ int main(int argc, char* argv[]) {
Display display{window, {0, 0}, {1000, 1000}};
Stats cycle_stats;
Stats render_stats;
Stats update_stats;
while (display.active()) {
auto currentTime = std::chrono::high_resolution_clock::now();
@ -107,12 +108,16 @@ int main(int argc, char* argv[]) {
cycle_stats.sample_time(t);
}
auto t = render_stats.time_start();
auto ut = update_stats.time_start();
display.update(chip8);
update_stats.sample_time(ut);
auto rt = render_stats.time_start();
display.render();
render_stats.sample_time(t);
render_stats.sample_time(rt);
}
cycle_stats.dump("cycle times");
render_stats.dump("render times");
cycle_stats.dump("CYCLE TIMES");
update_stats.dump("UPDATE TIMES");
render_stats.dump("RENDER TIMES");
}

Loading…
Cancel
Save