77#include < string_view>
88
99static constexpr size_t WIDTH = 768 ;
10+ static constexpr size_t HEIGHT = 280 ;
1011static constexpr size_t FRAMES = 10000 ;
12+ static constexpr size_t FRAMES_CURSOR = 10'000'000 ;
1113
1214static constexpr std::array<uint8_t , WIDTH> LINEA{};
1315static constexpr std::array<uint8_t , WIDTH> LINEB{};
@@ -23,15 +25,14 @@ static void benchmarkRenderer(std::string_view name)
2325 renderer.m_codingMethod [B] = CODINGB;
2426 renderer.m_bps [A] = BPS;
2527 renderer.m_bps [B] = BPS;
28+ renderer.SetDisplayFormat (Video::Renderer::DisplayFormat::PAL);
2629 renderer.m_mix = true ;
2730
28- const size_t height = renderer.m_plane [A].m_height ;
29-
3031 // Benchmark
3132 const std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now ();
3233 for (size_t f = 0 ; f < FRAMES; ++f)
3334 {
34- for (size_t y = 0 ; y < height ; ++y)
35+ for (size_t y = 0 ; y < HEIGHT ; ++y)
3536 {
3637 renderer.DrawLine (LINEA.data (), LINEB.data ());
3738 }
@@ -41,21 +42,48 @@ static void benchmarkRenderer(std::string_view name)
4142 const std::chrono::high_resolution_clock::time_point finish = std::chrono::high_resolution_clock::now ();
4243 const std::chrono::nanoseconds delta = finish - start;
4344
44- std::print (" {} " , name);
45- std::println ( " {} {} {}/f {} " ,
45+ std::println (" {} {} {} {}/f {} " ,
46+ name ,
4647 delta,
4748 std::chrono::duration_cast<std::chrono::microseconds>(delta),
4849 std::chrono::duration_cast<std::chrono::microseconds>(delta / FRAMES),
4950 std::chrono::duration_cast<std::chrono::milliseconds>(delta)
5051 );
5152}
5253
54+ template <typename RENDERER>
55+ static void benchmarkRendererCursor (std::string_view name)
56+ {
57+ RENDERER renderer;
58+ renderer.SetDisplayFormat (Video::Renderer::DisplayFormat::PAL);
59+
60+ // Benchmark
61+ const std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now ();
62+ for (size_t f = 0 ; f < FRAMES_CURSOR; ++f)
63+ {
64+ renderer.DrawCursor ();
65+ }
66+ const std::chrono::high_resolution_clock::time_point finish = std::chrono::high_resolution_clock::now ();
67+ const std::chrono::nanoseconds delta = finish - start;
68+
69+ std::println (" {} {} {} {}/f {}" ,
70+ name,
71+ delta,
72+ std::chrono::duration_cast<std::chrono::microseconds>(delta),
73+ delta / FRAMES_CURSOR,
74+ std::chrono::duration_cast<std::chrono::milliseconds>(delta)
75+ );
76+ }
77+
5378int main ()
5479{
5580 constexpr Video::Renderer::BitsPerPixel NORMAL_8 = Video::Renderer::BitsPerPixel::Normal8;
5681 constexpr Video::Renderer::BitsPerPixel DOUBLE_4 = Video::Renderer::BitsPerPixel::Double4;
5782 // constexpr Video::Renderer::BitsPerPixel HIGH_8 = Video::Renderer::BitsPerPixel::High8;
5883
84+ benchmarkRendererCursor<Video::RendererSoftware>(" Cursor Soft" );
85+ benchmarkRendererCursor<Video::RendererSIMD>(" Cursor SIMD" );
86+
5987 benchmarkRenderer<Video::RendererSoftware, NORMAL_8, ICM (OFF), ICM (RGB555)>(" Normal Soft RGB555" );
6088 benchmarkRenderer<Video::RendererSIMD, NORMAL_8, ICM (OFF), ICM (RGB555)>(" Normal SIMD RGB555" );
6189
0 commit comments