From 0f224e134234a6fb880613babd45942ece918f92 Mon Sep 17 00:00:00 2001 From: "Leandro A. F. Pereira" Date: Fri, 27 Oct 2006 14:51:46 +0000 Subject: Cleanups. Fallback to using hardcoded paths if binreloc fails. Add GTK+ log handler (shows errors and warnings in a graphical window). --- hardinfo2/arch/common/fib.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'hardinfo2/arch/common/fib.h') diff --git a/hardinfo2/arch/common/fib.h b/hardinfo2/arch/common/fib.h index 9f2d4e77..a218c90c 100644 --- a/hardinfo2/arch/common/fib.h +++ b/hardinfo2/arch/common/fib.h @@ -16,12 +16,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -static unsigned long long -fib(unsigned long long n) +static unsigned int +fib(unsigned int 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); } @@ -30,16 +30,21 @@ static gchar * benchmark_fib(void) { GTimer *timer = g_timer_new(); - gdouble elapsed = 0; + gdouble elapsed = 1.0; + gint i; shell_view_set_enabled(FALSE); shell_status_update("Calculating the 42nd Fibonacci number..."); - g_timer_start(timer); - fib(42); /* the answer? :) */ - g_timer_stop(timer); - - elapsed = g_timer_elapsed(timer, NULL); + 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_destroy(timer); -- cgit v1.2.3