From d9f77003caadb032ea53085dbf66fb8083f8f56a Mon Sep 17 00:00:00 2001 From: "Leandro A. F. Pereira" Date: Sun, 19 Nov 2006 12:02:55 +0000 Subject: Fix fibonacci benchmark --- hardinfo2/arch/common/fib.h | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'hardinfo2/arch') diff --git a/hardinfo2/arch/common/fib.h b/hardinfo2/arch/common/fib.h index a218c90c..7dd4279e 100644 --- a/hardinfo2/arch/common/fib.h +++ b/hardinfo2/arch/common/fib.h @@ -16,8 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -static unsigned int -fib(unsigned int n) +static gulong +fib(gulong n) { if (n == 0) return 0; @@ -30,25 +30,21 @@ static gchar * benchmark_fib(void) { GTimer *timer = g_timer_new(); - gdouble elapsed = 1.0; - gint i; + gdouble elapsed; shell_view_set_enabled(FALSE); shell_status_update("Calculating the 42nd Fibonacci number..."); - for (i = 0; i < 3; i++) { - g_timer_reset(timer); - g_timer_start(timer); - fib(42); /* the answer? :) */ - g_timer_stop(timer); - elapsed *= g_timer_elapsed(timer, NULL); - } - - elapsed = pow(elapsed, 1 / 3.0); + g_timer_reset(timer); + g_timer_start(timer); + + fib(42); + g_timer_stop(timer); + elapsed = g_timer_elapsed(timer, NULL); g_timer_destroy(timer); gchar *retval = g_strdup_printf("[Results (in seconds; lower is better)]\n" - "This Machine=%.2f\n", elapsed); + "This Machine=%.3f\n", elapsed); return benchmark_include_results(retval, "Fibonacci"); } -- cgit v1.2.3