mirror of
https://git.coom.tech/drummyfish/raycastlib.git
synced 2024-11-21 20:29:59 +01:00
Add benchmark
This commit is contained in:
parent
12cfd9f0fb
commit
b1146d8f05
1 changed files with 35 additions and 0 deletions
35
test.c
35
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();
|
||||
|
|
Loading…
Reference in a new issue