diff options
author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2006-10-27 14:51:46 +0000 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2006-10-27 14:51:46 +0000 |
commit | 0f224e134234a6fb880613babd45942ece918f92 (patch) | |
tree | d453a4912c514a45955c2badcd8e0b187b6af5da /hardinfo2/arch | |
parent | e5c7cba7ec1deb207ff5b6b93815d8d15e84d270 (diff) |
Cleanups. Fallback to using hardcoded paths if binreloc fails. Add GTK+ log handler (shows errors and warnings in a graphical window).
Diffstat (limited to 'hardinfo2/arch')
-rw-r--r-- | hardinfo2/arch/common/fib.h | 23 |
1 files changed, 14 insertions, 9 deletions
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); |