diff options
Diffstat (limited to 'arch/common/fib.h')
-rw-r--r-- | arch/common/fib.h | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/arch/common/fib.h b/arch/common/fib.h index 493cfd0f..645002fa 100644 --- a/arch/common/fib.h +++ b/arch/common/fib.h @@ -1,6 +1,6 @@ /* * HardInfo - Displays System Information - * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> * * 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 @@ -16,35 +16,33 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -static unsigned long long -fib(unsigned long long n) +static gulong +fib(gulong n) { if (n == 0) return 0; - else if (n == 1 || n == 2) + else if (n <= 2) return 1; return fib(n - 1) + fib(n - 2); } -static gchar * +static void benchmark_fib(void) { GTimer *timer = g_timer_new(); - gdouble elapsed = 0; + gdouble elapsed; shell_view_set_enabled(FALSE); - shell_status_update("Calculating the 42<sup>th</sup> Fibonacci number..."); + shell_status_update("Calculating the 42nd Fibonacci number..."); + g_timer_reset(timer); g_timer_start(timer); - fib(42); /* the answer? :) */ - g_timer_stop(timer); - elapsed = g_timer_elapsed(timer, NULL); + fib(42); + g_timer_stop(timer); + elapsed = g_timer_elapsed(timer, NULL); g_timer_destroy(timer); - - gchar *retval = g_strdup_printf("[Results <i>(in seconds; lower is better)</i>]\n" - "<b>This Machine</b>=<b>%.2f</b>\n", elapsed); - return benchmark_include_results(retval, "Fibonacci"); + + bench_results[BENCHMARK_FIB] = elapsed; } - |