diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/benchmark.c | 17 | ||||
| -rw-r--r-- | modules/benchmark/zlib.c | 71 | 
2 files changed, 88 insertions, 0 deletions
diff --git a/modules/benchmark.c b/modules/benchmark.c index 94997df8..de9e67c3 100644 --- a/modules/benchmark.c +++ b/modules/benchmark.c @@ -36,6 +36,7 @@ void scan_bfsh(gboolean reload);  void scan_cryptohash(gboolean reload);  void scan_fib(gboolean reload);  void scan_nqueens(gboolean reload); +void scan_zlib(gboolean reload);  void scan_gui(gboolean reload);  gchar *callback_fft(); @@ -44,6 +45,7 @@ gchar *callback_bfsh();  gchar *callback_fib();  gchar *callback_cryptohash();  gchar *callback_nqueens(); +gchar *callback_zlib();  gchar *callback_gui();  static ModuleEntry entries[] = { @@ -51,6 +53,7 @@ static ModuleEntry entries[] = {      {N_("CPU CryptoHash"), "cryptohash.png", callback_cryptohash, scan_cryptohash, MODULE_FLAG_NONE},      {N_("CPU Fibonacci"), "nautilus.png", callback_fib, scan_fib, MODULE_FLAG_NONE},      {N_("CPU N-Queens"), "nqueens.png", callback_nqueens, scan_nqueens, MODULE_FLAG_NONE}, +    {N_("CPU Zlib"), "module.png", callback_zlib, scan_zlib, MODULE_FLAG_NONE},      {N_("FPU FFT"), "fft.png", callback_fft, scan_fft, MODULE_FLAG_NONE},      {N_("FPU Raytracing"), "raytrace.png", callback_raytr, scan_raytr, MODULE_FLAG_NONE},      {N_("GPU Drawing"), "module.png", callback_gui, scan_gui, MODULE_FLAG_NO_REMOTE}, @@ -306,6 +309,12 @@ gchar *callback_fib()  				     "CPU Fibonacci");  } +gchar *callback_zlib() +{ +    return benchmark_include_results(bench_results[BENCHMARK_ZLIB], +				     "CPU Zlib"); +} +  typedef struct _BenchmarkDialog BenchmarkDialog;  struct _BenchmarkDialog {      GtkWidget *dialog; @@ -504,12 +513,20 @@ void scan_fib(gboolean reload)      SCAN_END();  } +void scan_zlib(gboolean reload) +{ +    SCAN_START(); +    do_benchmark(benchmark_zlib, BENCHMARK_ZLIB); +    SCAN_END(); +} +  const gchar *hi_note_func(gint entry)  {      switch (entry) {      case BENCHMARK_CRYPTOHASH:  	return _("Results in MiB/second. Higher is better."); +    case BENCHMARK_ZLIB:      case BENCHMARK_GUI:          return _("Results in HIMarks. Higher is better."); diff --git a/modules/benchmark/zlib.c b/modules/benchmark/zlib.c new file mode 100644 index 00000000..eeec9d0e --- /dev/null +++ b/modules/benchmark/zlib.c @@ -0,0 +1,71 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2017 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    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. + * + *    This program is distributed in the hope that it will be useful, + *    but WITHOUT ANY WARRANTY; without even the implied warranty of + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *    GNU General Public License for more details. + * + *    You should have received a copy of the GNU General Public License + *    along with this program; if not, write to the Free Software + *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#include <glib.h> +#include <stdlib.h> +#include <zlib.h> + +#include "benchmark.h" + +static gpointer zlib_for(unsigned int start, unsigned int end, void *data, gint thread_number) +{ +    char *compressed; +    uLong bound = compressBound(bound); +    unsigned int i; + +    compressed = malloc(bound); +    if (!compressed) +        return NULL; +     +    for (i = start; i <= end; i++) {  +        char uncompressed[65536]; +        uLong compressedBound = bound; +        uLong destBound = sizeof(uncompressed); + +        compress(compressed, &compressedBound, data, 65536); +        uncompress(uncompressed, &destBound, compressed, compressedBound); +    } + +    free(compressed); +     +    return NULL; +} + +void +benchmark_zlib(void) +{ +    gdouble elapsed = 0; +    gchar *tmpsrc, *bdata_path; +     +    bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL); +    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { +        g_free(bdata_path); +        return; +    }      +     +    shell_view_set_enabled(FALSE); +    shell_status_update("Running Zlib benchmark..."); +         +    elapsed = benchmark_parallel_for(0, 50000, zlib_for, tmpsrc); +     +    g_free(bdata_path); +    g_free(tmpsrc); + +    gdouble marks = (50000. * 65536.) / (elapsed * 840205128.); +    bench_results[BENCHMARK_ZLIB] = marks; +}  | 
