Skip to content
This repository was archived by the owner on Dec 17, 2025. It is now read-only.

Commit 5a9d7d7

Browse files
authored
Fix and improve capi_benchmark (#480)
- Add missing stdbool.h include for bool type - Remove cutoff parameter from spir_sve_result_new call (API change) - Refactor main() to use benchmark_internal() function - Add multiple benchmark parameter sets for better coverage - Improve code organization and maintainability
1 parent 659b2fb commit 5a9d7d7

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

capi_benchmark/benchmark1.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <assert.h>
66
#include <sparseir/sparseir.h>
77
#include <time.h>
8+
#include <stdbool.h>
89

910
// Simple benchmark utilities
1011
typedef struct
@@ -51,13 +52,12 @@ int benchmark(double beta, double omega_max, double epsilon, int extra_size, int
5152
benchmark_end(&bench);
5253

5354
// Create a pre-computed SVE result
54-
double cutoff = -1.0;
5555
int lmax = -1;
5656
int n_gauss = -1;
5757
int Twork = SPIR_TWORK_FLOAT64X2;
5858
benchmark_start(&bench, "SVE computation");
5959
spir_sve_result *sve_logistic = spir_sve_result_new(
60-
kernel, epsilon, cutoff, lmax, n_gauss, Twork, &status);
60+
kernel, epsilon, lmax, n_gauss, Twork, &status);
6161
assert(status == SPIR_COMPUTATION_SUCCESS);
6262
assert(sve_logistic != NULL);
6363
benchmark_end(&bench);
@@ -200,11 +200,9 @@ int benchmark(double beta, double omega_max, double epsilon, int extra_size, int
200200
}
201201

202202

203-
int main()
203+
int benchmark_internal(double beta, double epsilon)
204204
{
205-
double beta = 1e+5; // Inverse temperature
206205
double omega_max = 1.0; // Ultraviolet cutoff
207-
double epsilon = 1e-10; // Accuracy target
208206

209207
int extra_size = 1000; // dimension of the extra space
210208

@@ -219,4 +217,18 @@ int main()
219217
printf("\n");
220218

221219
return 0;
222-
}
220+
}
221+
222+
223+
int main()
224+
{
225+
printf("Benchmark (beta = 1e+3, epsilon = 1e-6)\n");
226+
benchmark_internal(1e+3, 1e-6);
227+
printf("\n");
228+
229+
printf("Benchmark (beta = 1e+5, epsilon = 1e-10)\n");
230+
benchmark_internal(1e+5, 1e-10);
231+
232+
return 0;
233+
}
234+

0 commit comments

Comments
 (0)