summaryrefslogtreecommitdiff
path: root/hardinfo2/arch
diff options
context:
space:
mode:
authorLeandro A. F. Pereira <leandro@hardinfo.org>2006-11-19 12:02:55 +0000
committerLeandro A. F. Pereira <leandro@hardinfo.org>2006-11-19 12:02:55 +0000
commitd9f77003caadb032ea53085dbf66fb8083f8f56a (patch)
treec7bec63a9b2cdde52bb4a993a2c232eaec979490 /hardinfo2/arch
parent86f265dc18119d15e6439ee9c626a2961298274c (diff)
Fix fibonacci benchmark
Diffstat (limited to 'hardinfo2/arch')
-rw-r--r--hardinfo2/arch/common/fib.h24
1 files changed, 10 insertions, 14 deletions
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 <i>(in seconds; lower is better)</i>]\n"
- "<b>This Machine</b>=<b>%.2f</b>\n", elapsed);
+ "<b>This Machine</b>=<b>%.3f</b>\n", elapsed);
return benchmark_include_results(retval, "Fibonacci");
}