Skip to content

Commit

Permalink
SpriteHandler_examples.h:
Browse files Browse the repository at this point in the history
* Benchmarking example2() by displaying the measured FPS value at the end.
  • Loading branch information
razterizer committed Nov 8, 2024
1 parent 6461385 commit 5f5184c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Examples/SpriteHandler_examples.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../ScreenUtils.h"
#include "../Dynamics/CollisionHandler.h"
#include "../Dynamics/DynamicsSystem.h"
#include <Core/Benchmark.h>

bool use_dynamics_system = true;
bool dbg_draw_sprites = false;
Expand Down Expand Up @@ -268,13 +269,16 @@ namespace sprite_handler
// LET's GO ! //
// ///////////////////////////////////////////////////////////

const int delay = 0'20'000;
const int delay = 20'000;
const float dt = 1e-6f * delay;

begin_screen();

benchmark::tic();

int anim_frame = 0;
for (int i = 0; i < 2000; ++i)
const int num_frames = 2000;
for (int i = 0; i < num_frames; ++i)
{
if (use_dynamics_system)
{
Expand Down Expand Up @@ -314,7 +318,11 @@ namespace sprite_handler
}

quit:
auto dur_s = 1e-3f * benchmark::toc();
end_screen(sh);

auto fps = num_frames / dur_s;
std::cout << "FPS = " << fps << std::endl;
}

}

0 comments on commit 5f5184c

Please sign in to comment.