diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2024-04-22 00:35:53 -0300 | 
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2024-04-22 00:35:53 -0300 | 
| commit | 5f01c706267c595de92406a32e7f31ef5056c2d0 (patch) | |
| tree | d1e74ef54efc41ada622900fe3e2a50dee44a237 /modules/benchmark/fib.c | |
| parent | 09fcc751ef158898c315ebc9299a0fa3a722d914 (diff) | |
New upstream version 2.0.3preupstream/2.0.3pre
Diffstat (limited to 'modules/benchmark/fib.c')
| -rw-r--r-- | modules/benchmark/fib.c | 35 | 
1 files changed, 22 insertions, 13 deletions
| diff --git a/modules/benchmark/fib.c b/modules/benchmark/fib.c index d75ac367..2bec8bed 100644 --- a/modules/benchmark/fib.c +++ b/modules/benchmark/fib.c @@ -1,10 +1,10 @@  /* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org> + *    HardInfo - System Information and Benchmark + *    Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.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 - *    the Free Software Foundation, version 2. + *    the Free Software Foundation, version 2 or later.   *   *    This program is distributed in the hope that it will be useful,   *    but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,6 +18,11 @@  #include "benchmark.h" +/* if anything changes in this block, increment revision */ +#define BENCH_REVISION 2 +#define ANSWER 25 +#define CRUNCH_TIME 5 +  gulong fib(gulong n)  {      if (n == 0) @@ -27,6 +32,14 @@ gulong fib(gulong n)      return fib(n - 1) + fib(n - 2);  } +static gpointer fib_for(void *in_data, gint thread_number) +{ +    fib(ANSWER); + +    return NULL; +} + +  void  benchmark_fib(void)  { @@ -34,19 +47,15 @@ benchmark_fib(void)      bench_value r = EMPTY_BENCH_VALUE;      shell_view_set_enabled(FALSE); -    shell_status_update("Calculating the 42nd Fibonacci number..."); - -    g_timer_reset(timer); -    g_timer_start(timer); +    shell_status_update("Calculating Fibonacci number..."); -    fib(42); +    r = benchmark_crunch_for(CRUNCH_TIME, 0, fib_for, NULL); +    //r.threads_used = 1; -    g_timer_stop(timer); -    r.elapsed_time = g_timer_elapsed(timer, NULL); -    g_timer_destroy(timer); +    r.result /= 100; -    r.threads_used = 1; -    r.result = r.elapsed_time; +    r.revision = BENCH_REVISION; +    snprintf(r.extra, 255, "a:%d", ANSWER);      bench_results[BENCHMARK_FIB] = r;  } | 
