Permalink
Browse files

Add zlib benchmark

  • Loading branch information...
lpereira committed Jul 3, 2017
1 parent 0331395 commit e9d69db8341ee7452ce4e8f8dc54e972b0390bfe
Showing with 95 additions and 0 deletions.
  1. +5 −0 CMakeLists.txt
  2. +2 −0 includes/benchmark.h
  3. +17 −0 modules/benchmark.c
  4. +71 −0 modules/benchmark/zlib.c
  5. BIN pixmaps/file-roller.png
View
@@ -59,13 +59,16 @@ 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
${CMAKE_SOURCE_DIR}/includes/${HARDINFO_ARCH}
${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)
View
@@ -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);
View
@@ -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,13 +45,15 @@ gchar *callback_bfsh();
gchar *callback_fib();
gchar *callback_cryptohash();
gchar *callback_nqueens();
gchar *callback_zlib();
gchar *callback_gui();
static ModuleEntry entries[] = {
{N_("CPU Blowfish"), "blowfish.png", callback_bfsh, scan_bfsh, MODULE_FLAG_NONE},
{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.");
View
@@ -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;
}
View
Binary file not shown.

0 comments on commit e9d69db

Please sign in to comment.