diff options
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rw-r--r-- | includes/benchmark.h | 2 | ||||
-rw-r--r-- | modules/benchmark.c | 17 | ||||
-rw-r--r-- | modules/benchmark/zlib.c | 71 | ||||
-rw-r--r-- | pixmaps/file-roller.png | bin | 0 -> 1444 bytes |
5 files changed, 95 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ae29a99e..d0665ac9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,8 @@ if(NOT HARDINFO_NOSYNC) pkg_check_modules(LIBSOUP libsoup-2.4>=2.24) endif() +include(FindZLIB REQUIRED) + include_directories( ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/includes @@ -66,6 +68,7 @@ include_directories( ${CMAKE_BINARY_DIR} ${GTK_INCLUDE_DIRS} ${LIBSOUP_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIRS} ) link_directories( ${GTK_LIBRARY_DIRS} @@ -134,6 +137,7 @@ set(MODULE_benchmark_SOURCES modules/benchmark/nqueens.c modules/benchmark/raytrace.c modules/benchmark/sha1.c + modules/benchmark/zlib.c ) set_source_files_properties( @@ -173,6 +177,7 @@ target_link_libraries(hardinfo ${LIBSOUP_LIBRARIES} hardinfo-shell m + ${ZLIB_LIBRARIES} ) configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h @ONLY) diff --git a/includes/benchmark.h b/includes/benchmark.h index 8047d5c6..39de042b 100644 --- a/includes/benchmark.h +++ b/includes/benchmark.h @@ -10,6 +10,7 @@ enum { BENCHMARK_CRYPTOHASH, BENCHMARK_FIB, BENCHMARK_NQUEENS, + BENCHMARK_ZLIB, BENCHMARK_FFT, BENCHMARK_RAYTRACE, BENCHMARK_GUI, @@ -24,6 +25,7 @@ void benchmark_fish(void); void benchmark_gui(void); void benchmark_nqueens(void); void benchmark_raytrace(void); +void benchmark_zlib(void); gdouble benchmark_parallel_for(guint start, guint end, gpointer callback, gpointer callback_data); 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; +} diff --git a/pixmaps/file-roller.png b/pixmaps/file-roller.png Binary files differnew file mode 100644 index 00000000..5c17e91b --- /dev/null +++ b/pixmaps/file-roller.png |