Update benchmarks

This commit is contained in:
Minseong Jang
2025-06-13 15:19:21 +09:00
parent 49410f5264
commit 1aa18bce30
11 changed files with 201 additions and 193 deletions

View File

@@ -1,59 +1,59 @@
typedef struct { typedef struct {
int a; int a;
int b; int b;
} small; } small;
typedef struct { typedef struct {
long a; long a;
long b; long b;
long c; long c;
long d; long d;
long e; long e;
long f; long f;
long g; long g;
long h; long h;
} large; } large;
typedef struct { typedef struct {
long a; long a;
float b; float b;
} small_ugly; } small_ugly;
typedef struct { typedef struct {
long a; long a;
float b; float b;
long c; long c;
double d; double d;
long e; long e;
long f; long f;
long g; long g;
double h; double h;
long i; long i;
long j; long j;
long k; long k;
double l; double l;
} large_ugly; } large_ugly;
int exotic_arguments_struct_small(small a, int nonce) { int exotic_arguments_struct_small(small a, int nonce) {
return a.a + a.b + nonce; return a.a + a.b + nonce;
} }
long exotic_arguments_struct_large(large a, int nonce) { long exotic_arguments_struct_large(large a, int nonce) {
return a.a + a.b + a.c + a.d + a.e + a.f + a.g + a.h + nonce; return a.a + a.b + a.c + a.d + a.e + a.f + a.g + a.h + nonce;
} }
float exotic_arguments_struct_small_ugly(small_ugly a, int nonce) { float exotic_arguments_struct_small_ugly(small_ugly a, int nonce) {
return 0.0f + a.a + a.b + nonce; return 0.0f + a.a + a.b + nonce;
} }
double exotic_arguments_struct_large_ugly(large_ugly a, int nonce) { double exotic_arguments_struct_large_ugly(large_ugly a, int nonce) {
return 0.0 + a.a + a.b + a.c + a.d + a.e + a.f + a.g + a.h + nonce; return 0.0 + a.a + a.b + a.c + a.d + a.e + a.f + a.g + a.h + nonce;
} }
float exotic_arguments_float(float a, int nonce) { float exotic_arguments_float(float a, int nonce) {
return a + (float) nonce; return a + (float)nonce;
} }
double exotic_arguments_double(double a, int nonce) { double exotic_arguments_double(double a, int nonce) {
return a + (double) nonce; return a + (double)nonce;
} }

View File

@@ -1,36 +1,36 @@
int fibonacci_loop(int n, int nonce) { int fibonacci_loop(int n, int nonce) {
int result = 0; int result = 0;
for (int step = 0; step < 10; ++step) { for (int step = 0; step < 10; ++step) {
int x = nonce; int x = nonce;
int y = nonce; int y = nonce;
for (int i = 1; i < n; ++i) { for (int i = 1; i < n; ++i) {
int newy = x + y; int newy = x + y;
newy += (x + y); newy += (x + y);
newy += (x + y); newy += (x + y);
newy += (x + y); newy += (x + y);
newy += (x + y); newy += (x + y);
newy += (x + y); newy += (x + y);
newy -= (x + y); newy -= (x + y);
newy -= (x + y); newy -= (x + y);
newy -= (x + y); newy -= (x + y);
newy -= (x + y); newy -= (x + y);
newy -= (x + y); newy -= (x + y);
x = y; x = y;
y = newy; y = newy;
}
result += y;
} }
result += y; return result;
}
return result;
} }
int fibonacci_recursive(int n, int nonce) { int fibonacci_recursive(int n, int nonce) {
if (n < 2) { if (n < 2) {
return nonce; return nonce;
} }
return fibonacci_recursive(n - 1, nonce) + fibonacci_recursive(n - 2, nonce); return fibonacci_recursive(n - 1, nonce) + fibonacci_recursive(n - 2, nonce);
} }

View File

@@ -2,96 +2,101 @@ int graph_weight[1000][1000];
int graph_dijkstra_dist[1000]; int graph_dijkstra_dist[1000];
int graph_dijkstra_visited[1000]; int graph_dijkstra_visited[1000];
void graph_weight_init(int n, int nonce, int *x, int (*weight)[1000]) { void graph_weight_init(int n, int nonce, int* x, int (*weight)[1000]) {
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
weight[i][i] = 0; weight[i][i] = 0;
for (int j = 1; j < n; ++j) { for (int j = 1; j < n; ++j) {
weight[i][(i + j) % n] = ++*x; weight[i][(i + j) % n] = ++*x;
if (*x % (nonce + 1)) { if (*x % (nonce + 1)) {
++*x; ++*x;
} }
}
} }
}
} }
int graph_dijkstra(int n, int nonce) { int graph_dijkstra(int n, int nonce) {
if (!(n <= 1000)) { if (!(n <= 1000)) {
return nonce; return nonce;
}
int x = 0;
graph_weight_init(n, nonce, &x, graph_weight);
for (int i = 0; i < n; ++i) {
graph_dijkstra_dist[i] = -1;
graph_dijkstra_visited[i] = 0;
}
graph_dijkstra_dist[0] = 0;
for (int step = 0; step < n; ++step) {
int v = -1;
for (int i = 0; i < n; ++i) {
if (!(graph_dijkstra_dist[i] != -1 && !graph_dijkstra_visited[i])) {
continue;
}
if (v != -1 && graph_dijkstra_dist[v] < graph_dijkstra_dist[i]) {
continue;
}
v = i;
} }
if (v == -1) { int x = 0;
break; graph_weight_init(n, nonce, &x, graph_weight);
}
int dist = graph_dijkstra_dist[v];
graph_dijkstra_visited[v] = 1;
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
if (graph_dijkstra_visited[i]) continue; graph_dijkstra_dist[i] = -1;
if (graph_dijkstra_dist[i] != -1 && graph_dijkstra_dist[i] < dist + graph_weight[v][i]) continue; graph_dijkstra_visited[i] = 0;
graph_dijkstra_dist[i] = dist + graph_weight[v][i];
} }
} graph_dijkstra_dist[0] = 0;
int result = 0; for (int step = 0; step < n; ++step) {
for (int i = 0; i < n; ++i) { int v = -1;
result += graph_dijkstra_dist[i]; for (int i = 0; i < n; ++i) {
} if (!(graph_dijkstra_dist[i] != -1 && !graph_dijkstra_visited[i])) {
continue;
}
return result; if (v != -1 && graph_dijkstra_dist[v] < graph_dijkstra_dist[i]) {
continue;
}
v = i;
}
if (v == -1) {
break;
}
int dist = graph_dijkstra_dist[v];
graph_dijkstra_visited[v] = 1;
for (int i = 0; i < n; ++i) {
if (graph_dijkstra_visited[i])
continue;
if (graph_dijkstra_dist[i] != -1 && graph_dijkstra_dist[i] < dist + graph_weight[v][i])
continue;
graph_dijkstra_dist[i] = dist + graph_weight[v][i];
}
}
int result = 0;
for (int i = 0; i < n; ++i) {
result ^= graph_dijkstra_dist[i];
}
return result;
} }
int graph_floyd_warshall(int n, int nonce) { int graph_floyd_warshall(int n, int nonce) {
if (!(n <= 1000)) { if (!(n <= 1000)) {
return nonce; return nonce;
} }
int x = 0; int x = 0;
graph_weight_init(n, nonce, &x, graph_weight); graph_weight_init(n, nonce, &x, graph_weight);
for (int k = 0; k < n; ++k) { for (int k = 0; k < n; ++k) {
for (int i = 0; i < n; ++i) {
if (graph_weight[i][k] == -1)
continue;
for (int j = 0; j < n; ++j) {
if (graph_weight[k][j] == -1)
continue;
int weight = graph_weight[i][k] + graph_weight[k][j];
if (graph_weight[i][j] != -1 && graph_weight[i][j] < weight)
continue;
graph_weight[i][j] = weight;
}
}
}
int result = 0;
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
if (graph_weight[i][k] == -1) continue; for (int j = 0; j < n; ++j) {
result ^= graph_weight[i][j];
for (int j = 0; j < n; ++j) { }
if (graph_weight[k][j] == -1) continue;
int weight = graph_weight[i][k] + graph_weight[k][j];
if (graph_weight[i][j] != -1 && graph_weight[i][j] < weight) continue;
graph_weight[i][j] = weight;
}
} }
} return result;
int result = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
result += graph_weight[i][j];
}
}
return result;
} }

View File

@@ -2,57 +2,57 @@ int matrix_a[30][30];
int matrix_b[30][30]; int matrix_b[30][30];
int matrix_c[30][30]; int matrix_c[30][30];
void matrix_init(int n, int nonce, int *x, int (*matrix)[30]) { void matrix_init(int n, int nonce, int* x, int (*matrix)[30]) {
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) { for (int j = 0; j < n; ++j) {
matrix[i][j] = ++*x; matrix[i][j] = ++*x;
if (*x % (nonce + 1)) { if (*x % (nonce + 1)) {
++*x; ++*x;
} }
}
} }
}
} }
int matrix_mul(int n, int nonce) { int matrix_mul(int n, int nonce) {
if (!(n <= 30)) { if (!(n <= 30)) {
return nonce; return nonce;
}
int x = 0;
matrix_init(n, nonce, &x, matrix_a);
matrix_init(n, nonce, &x, matrix_b);
int result = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
matrix_c[i][j] = 0;
for (int k = 0; k < n; ++k) {
matrix_c[i][j] += matrix_a[i][k] * matrix_b[k][j];
}
result += matrix_c[i][j];
} }
}
return result; int x = 0;
matrix_init(n, nonce, &x, matrix_a);
matrix_init(n, nonce, &x, matrix_b);
int result = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
matrix_c[i][j] = 0;
for (int k = 0; k < n; ++k) {
matrix_c[i][j] += matrix_a[i][k] * matrix_b[k][j];
}
result ^= matrix_c[i][j];
}
}
return result;
} }
int matrix_add(int n, int nonce) { int matrix_add(int n, int nonce) {
if (!(n <= 30)) { if (!(n <= 30)) {
return nonce; return nonce;
}
int x = 0;
matrix_init(n, nonce, &x, matrix_a);
matrix_init(n, nonce, &x, matrix_b);
int result = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
matrix_c[i][j] = matrix_a[i][j] + nonce * matrix_b[i][j];
result += matrix_c[i][j];
} }
}
return result; int x = 0;
matrix_init(n, nonce, &x, matrix_a);
matrix_init(n, nonce, &x, matrix_b);
int result = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
matrix_c[i][j] = matrix_a[i][j] + nonce * matrix_b[i][j];
result ^= matrix_c[i][j];
}
}
return result;
} }

View File

@@ -56,7 +56,7 @@ int verify_median(int n, int* test) {
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
int v = test[i]; int v = test[i];
result += v; result ^= v;
} }
return result; return result;

View File

@@ -26,6 +26,9 @@ int multiply(int x, int y) {
int result = 0; int result = 0;
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
if (x == 0)
break;
if ((x & 0x1) == 1) if ((x & 0x1) == 1)
result = result + y; result = result + y;
@@ -47,7 +50,7 @@ int verify_multiply(int n, int* test) {
if (t0 * t1 != v) if (t0 * t1 != v)
return 1; return 1;
result += v; result ^= v;
} }
return result; return result;

View File

@@ -115,7 +115,7 @@ int verify_qsort(int n, int* test) {
if (t0 > t1) if (t0 > t1)
return 1; return 1;
result += t0; result ^= t0;
} }
return result; return result;

View File

@@ -101,7 +101,7 @@ int verify_rsort(int n, int* test) {
if (t0 > t1) if (t0 > t1)
return 1; return 1;
result += t0; result ^= t0;
} }
return result; return result;

View File

@@ -74,7 +74,7 @@ int verifyDouble(int n, double* test) {
int result = 0; int result = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
result += (int) (test[i]); result ^= (int) (test[i]);
} }
return result; return result;

View File

@@ -1,24 +1,24 @@
int two_dimension_array_arr[100]; int two_dimension_array_arr[100];
int two_dimension_array(int n, int nonce) { int two_dimension_array(int n, int nonce) {
if (!(n <= 100)) { if (!(n <= 100)) {
return nonce; return nonce;
}
for (int i = 0; i < n; ++i) {
two_dimension_array_arr[i] = i + nonce;
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
two_dimension_array_arr[i] += two_dimension_array_arr[j];
} }
}
int result = 0; for (int i = 0; i < n; ++i) {
for (int i = 0; i < n; ++i) { two_dimension_array_arr[i] = i + nonce;
result += two_dimension_array_arr[i]; }
}
return result; for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
two_dimension_array_arr[i] ^= two_dimension_array_arr[j];
}
}
int result = 0;
for (int i = 0; i < n; ++i) {
result += two_dimension_array_arr[i];
}
return result;
} }

View File

@@ -35,7 +35,7 @@ int verify_vvadd(int n, int* test) {
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
int v = test[i]; int v = test[i];
result += v; result ^= v;
} }
return result; return result;