From b1146d8f0576b306cc582a41096b02d3b2b0bc75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Tue, 4 Sep 2018 12:39:26 +0200 Subject: [PATCH] Add benchmark --- test.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test.c b/test.c index 1154f9a..6e47cbb 100644 --- a/test.c +++ b/test.c @@ -93,6 +93,38 @@ void benchCastRays() } } +void benchmarkMapping() +{ + Vector2D v; + Camera c; + + c.resolution.x = 1024; + c.resolution.y = 768; + c.position.x = UNITS_PER_SQUARE / 2; + c.position.y = UNITS_PER_SQUARE * 2; + c.direction = UNITS_PER_SQUARE / 8; + c.height = 0; + c.fovAngle = UNITS_PER_SQUARE / 2; + + PixelInfo p; + + Vector2D pos; + Unit height; + + pos.x = -1024 * UNITS_PER_SQUARE; + pos.y = -512 * UNITS_PER_SQUARE; + height = 0; + + for (int i = 0; i < 1000000; ++i) + { + p = mapToScreen(pos,height,c); + + pos.x += 4; + pos.y += 8; + height = (height + 16) % 1024; + } +} + int main() { printf("Testing raycastlib.\n"); @@ -150,6 +182,9 @@ int main() long t; t = measureTime(benchCastRays); printf("cast 1000000 rays: %ld ms\n",t); + + t = measureTime(benchmarkMapping); + printf("map point to screen 1000000 times: %ld ms\n",t); printf("\n"); printProfile();