From 5f01c706267c595de92406a32e7f31ef5056c2d0 Mon Sep 17 00:00:00 2001 From: Lucas de Castro Borges Date: Mon, 22 Apr 2024 00:35:53 -0300 Subject: New upstream version 2.0.3pre --- modules/benchmark/fib.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'modules/benchmark/fib.c') diff --git a/modules/benchmark/fib.c b/modules/benchmark/fib.c index d75ac367..2bec8bed 100644 --- a/modules/benchmark/fib.c +++ b/modules/benchmark/fib.c @@ -1,10 +1,10 @@ /* - * HardInfo - Displays System Information - * Copyright (C) 2003-2007 Leandro A. F. Pereira + * HardInfo - System Information and Benchmark + * Copyright (C) 2003-2007 L. A. F. Pereira * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 2. + * the Free Software Foundation, version 2 or later. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,6 +18,11 @@ #include "benchmark.h" +/* if anything changes in this block, increment revision */ +#define BENCH_REVISION 2 +#define ANSWER 25 +#define CRUNCH_TIME 5 + gulong fib(gulong n) { if (n == 0) @@ -27,6 +32,14 @@ gulong fib(gulong n) return fib(n - 1) + fib(n - 2); } +static gpointer fib_for(void *in_data, gint thread_number) +{ + fib(ANSWER); + + return NULL; +} + + void benchmark_fib(void) { @@ -34,19 +47,15 @@ benchmark_fib(void) bench_value r = EMPTY_BENCH_VALUE; shell_view_set_enabled(FALSE); - shell_status_update("Calculating the 42nd Fibonacci number..."); - - g_timer_reset(timer); - g_timer_start(timer); + shell_status_update("Calculating Fibonacci number..."); - fib(42); + r = benchmark_crunch_for(CRUNCH_TIME, 0, fib_for, NULL); + //r.threads_used = 1; - g_timer_stop(timer); - r.elapsed_time = g_timer_elapsed(timer, NULL); - g_timer_destroy(timer); + r.result /= 100; - r.threads_used = 1; - r.result = r.elapsed_time; + r.revision = BENCH_REVISION; + snprintf(r.extra, 255, "a:%d", ANSWER); bench_results[BENCHMARK_FIB] = r; } -- cgit v1.2.3