Removed: Wierd benchmarking switch statement

This commit is contained in:
Yashar Alan Zenker
2026-07-05 00:25:29 +02:00
parent 5c6b678e0e
commit b87a5ee1f3
+17 -37
View File
@@ -28,60 +28,40 @@ unsigned tests(void) {
void benchmarking(size_t benchmarking_amount, int version_to_use, float complex complexA, size_t width, ssize_t height, float resolution, unsigned n, _Bool colored, unsigned char *tempArr) { void benchmarking(size_t benchmarking_amount, int version_to_use, float complex complexA, size_t width, ssize_t height, float resolution, unsigned n, _Bool colored, unsigned char *tempArr) {
struct timespec start; struct timespec start;
struct timespec end; struct timespec end;
void (*tricorn_implementation)(float complex, size_t, ssize_t, float, unsigned, _Bool, unsigned char*);
switch (version_to_use) switch (version_to_use)
{ {
case 0: // Uses highly optimized SIMD and threaded version / main implementation case 0: // Uses highly optimized SIMD and threaded version / main implementatio
clock_gettime(CLOCK_MONOTONIC, &start); tricorn_implementation = tricorn;
for (size_t i = 0; i < benchmarking_amount; i++)
{
tricorn(complexA,width,height,resolution,n,colored,tempArr);
}
clock_gettime(CLOCK_MONOTONIC, &end);
break; break;
case 1: // Uses unoptimised comparison implementation case 1: // Uses unoptimised comparison implementation
clock_gettime(CLOCK_MONOTONIC, &start); tricorn_implementation = tricorn_V1;
for (size_t i = 0; i < benchmarking_amount; i++)
{
tricorn_V1(complexA,width,height,resolution,n,colored,tempArr);
}
clock_gettime(CLOCK_MONOTONIC, &end);
break; break;
case 2: // Uses optimized SISD version case 2: // Uses optimized SISD version
clock_gettime(CLOCK_MONOTONIC, &start); tricorn_implementation = tricorn_V2;
for (size_t i = 0; i < benchmarking_amount; i++)
{
tricorn_V2(complexA,width,height,resolution,n,colored,tempArr);
}
clock_gettime(CLOCK_MONOTONIC, &end);
break; break;
case 3: // Uses unoptimized SIMD version case 3: // Uses unoptimized SIMD version
clock_gettime(CLOCK_MONOTONIC, &start); tricorn_implementation = tricorn_V3;
for (size_t i = 0; i < benchmarking_amount; i++)
{
tricorn_V3(complexA,width,height,resolution,n,colored,tempArr);
}
clock_gettime(CLOCK_MONOTONIC, &end);
break; break;
case 4: // Uses highly optimized SIMD case 4: // Uses highly optimized SIMD
clock_gettime(CLOCK_MONOTONIC, &start); tricorn_implementation = tricorn_V4;
for (size_t i = 0; i < benchmarking_amount; i++)
{
tricorn_V4(complexA,width,height,resolution,n,colored,tempArr);
}
clock_gettime(CLOCK_MONOTONIC, &end);
break; break;
case 5: // Experimental cleanups and inlines / for testing case 5: // Experimental cleanups and inlines / for testing
clock_gettime(CLOCK_MONOTONIC, &start); tricorn_implementation = tricorn_V5;
for (size_t i = 0; i < benchmarking_amount; i++)
{
tricorn_V5(complexA,width,height,resolution,n,colored,tempArr);
}
clock_gettime(CLOCK_MONOTONIC, &end);
break; break;
default: default:
printf("Invalid version to use"); printf("Invalid version to use");
return; return;
} }
clock_gettime(CLOCK_MONOTONIC, &start);
for (size_t i = 0; i < benchmarking_amount; i++)
{
tricorn_implementation(complexA,width,height,resolution,n,colored,tempArr);
}
clock_gettime(CLOCK_MONOTONIC, &end);
double time = end.tv_sec- start.tv_sec + 1e-9 * (end.tv_nsec- start.tv_nsec); double time = end.tv_sec- start.tv_sec + 1e-9 * (end.tv_nsec- start.tv_nsec);
printf("The total amount of time spent for %zu function calls: %lf\n", benchmarking_amount,time); printf("The total amount of time spent for %zu function calls: %lf\n", benchmarking_amount,time);
double average = time / benchmarking_amount; double average = time / benchmarking_amount;