aboutsummaryrefslogtreecommitdiff
path: root/modules/benchmark/nqueens.c
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2017-12-17 08:56:46 -0600
committerLeandro A. F. Pereira <leandro@hardinfo.org>2018-02-27 07:41:51 -0800
commitc8785521f39c3a86454ade890018ca021272c621 (patch)
tree4df2fa40ca918cb26460d07939136bef6a63ef13 /modules/benchmark/nqueens.c
parent8fb9ed49987ca006495891f04e5250496d6e00f4 (diff)
Benchmark results: store threads used
Benchmark results store actual number of threads used by benchmark when it was run. Previously, results assumed all available threads were used. Examples: * CPU Fib only uses one * FPU FFT uses 4, 2, or 1 * N-Queens uses 10, 5, 2, or 1 Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules/benchmark/nqueens.c')
-rw-r--r--modules/benchmark/nqueens.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/modules/benchmark/nqueens.c b/modules/benchmark/nqueens.c
index a32ed8c1..78293abb 100644
--- a/modules/benchmark/nqueens.c
+++ b/modules/benchmark/nqueens.c
@@ -25,7 +25,7 @@ bool safe(int x, int y)
int nqueens(int y)
{
int x;
-
+
for (x = 0; x < QUEENS; x++) {
if (safe((row[y - 1] = x), y - 1)) {
if (y < QUEENS) {
@@ -35,32 +35,33 @@ int nqueens(int y)
}
}
}
-
+
return 0;
}
static gpointer nqueens_for(unsigned int start, unsigned int end, void *data, gint thread_number)
{
unsigned int i;
-
- for (i = start; i <= end; i++) {
+
+ for (i = start; i <= end; i++) {
nqueens(0);
}
-
+
return NULL;
}
void
benchmark_nqueens(void)
{
- gdouble elapsed = 0;
-
+ bench_value r = EMPTY_BENCH_VALUE;
+
shell_view_set_enabled(FALSE);
shell_status_update("Running N-Queens benchmark...");
-
- elapsed = benchmark_parallel_for(0, 10, nqueens_for, NULL);
-
- bench_results[BENCHMARK_NQUEENS] = elapsed;
+
+ r = benchmark_parallel_for(0, 0, 10, nqueens_for, NULL);
+ r.result = r.elapsed_time;
+
+ bench_results[BENCHMARK_NQUEENS] = r;
}