diff options
| author | Burt P <pburt0@gmail.com> | 2018-10-21 00:42:31 -0500 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2018-11-04 15:02:46 -0800 | 
| commit | d5d0607e4da1bde37fc0072c65689d2ed0775ed1 (patch) | |
| tree | e0dfccc2a6e965870c9409e77e7bdfe4a8c5668a /modules/benchmark | |
| parent | f6299d9fad21c065d1e4c0f1093770835fb73adf (diff) | |
benchmark/blowfish: new version of blowfish benchmark
The new version uses a fixed time and provides variants for
single-thread, multi-thread, and multi-core.
A few results are included.
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules/benchmark')
| -rw-r--r-- | modules/benchmark/bench_results.c | 6 | ||||
| -rw-r--r-- | modules/benchmark/benches.c | 16 | ||||
| -rw-r--r-- | modules/benchmark/blowfish.c | 45 | ||||
| -rw-r--r-- | modules/benchmark/blowfish2.c | 86 | 
4 files changed, 102 insertions, 51 deletions
| diff --git a/modules/benchmark/bench_results.c b/modules/benchmark/bench_results.c index 92790edb..4f7b35db 100644 --- a/modules/benchmark/bench_results.c +++ b/modules/benchmark/bench_results.c @@ -377,6 +377,7 @@ static char *bench_result_more_info_less(bench_result *b) {      char *ret = g_strdup_printf("[%s]\n"          /* threads */   "%s=%d\n" +        /* elapsed */   "%s=%0.4f %s\n"          /* legacy */    "%s=%s\n"                          "[%s]\n"          /* board */     "%s=%s\n" @@ -389,6 +390,7 @@ static char *bench_result_more_info_less(bench_result *b) {          /* mem */       "%s=%s\n",                          _("Benchmark Result"),                          _("Threads"), b->bvalue.threads_used, +                        _("Elapsed Time"), b->bvalue.elapsed_time, _("seconds"),                          b->legacy ? _("Note") : "#Note",                          b->legacy ? _("This result is from an old version of HardInfo. Results might not be comparable to current version. Some details are missing.") : "",                          _("Machine"), @@ -410,7 +412,7 @@ static char *bench_result_more_info_complete(bench_result *b) {          /* bench name */"%s=%s\n"          /* threads */   "%s=%d\n"          /* result */    "%s=%0.2f\n" -        /* elapsed */   "%s=%0.2f\n" +        /* elapsed */   "%s=%0.4f %s\n"          /* legacy */    "%s=%s\n"                          "[%s]\n"          /* board */     "%s=%s\n" @@ -428,7 +430,7 @@ static char *bench_result_more_info_complete(bench_result *b) {                          _("Benchmark"), b->name,                          _("Threads"), b->bvalue.threads_used,                          _("Result"), b->bvalue.result, -                        _("Elapsed Time"), b->bvalue.elapsed_time, +                        _("Elapsed Time"), b->bvalue.elapsed_time, _("seconds"),                          b->legacy ? _("Note") : "#Note",                          b->legacy ? _("This result is from an old version of HardInfo. Results might not be comparable to current version. Some details are missing.") : "",                          _("Machine"), diff --git a/modules/benchmark/benches.c b/modules/benchmark/benches.c index e09dedcc..94571bc7 100644 --- a/modules/benchmark/benches.c +++ b/modules/benchmark/benches.c @@ -30,7 +30,9 @@ BENCH_CALLBACK(callback_gui, "GPU Drawing", BENCHMARK_GUI, 1);  BENCH_CALLBACK(callback_fft, "FPU FFT", BENCHMARK_FFT, 0);  BENCH_CALLBACK(callback_nqueens, "CPU N-Queens", BENCHMARK_NQUEENS, 0);  BENCH_CALLBACK(callback_raytr, "FPU Raytracing", BENCHMARK_RAYTRACE, 0); -BENCH_CALLBACK(callback_bfsh, "CPU Blowfish", BENCHMARK_BLOWFISH, 0); +BENCH_CALLBACK(callback_bfsh_single, "CPU Blowfish (Single-thread)", BENCHMARK_BLOWFISH_SINGLE, 0); +BENCH_CALLBACK(callback_bfsh_threads, "CPU Blowfish (Multi-thread)", BENCHMARK_BLOWFISH_THREADS, 0); +BENCH_CALLBACK(callback_bfsh_cores, "CPU Blowfish (Multi-core)", BENCHMARK_BLOWFISH_CORES, 0);  BENCH_CALLBACK(callback_cryptohash, "CPU CryptoHash", BENCHMARK_CRYPTOHASH, 1);  BENCH_CALLBACK(callback_fib, "CPU Fibonacci", BENCHMARK_FIB, 0);  BENCH_CALLBACK(callback_zlib, "CPU Zlib", BENCHMARK_ZLIB, 0); @@ -45,7 +47,9 @@ void SN(gboolean reload) { \  BENCH_SCAN_SIMPLE(scan_fft, benchmark_fft, BENCHMARK_FFT);  BENCH_SCAN_SIMPLE(scan_nqueens, benchmark_nqueens, BENCHMARK_NQUEENS);  BENCH_SCAN_SIMPLE(scan_raytr, benchmark_raytrace, BENCHMARK_RAYTRACE); -BENCH_SCAN_SIMPLE(scan_bfsh, benchmark_fish, BENCHMARK_BLOWFISH); +BENCH_SCAN_SIMPLE(scan_bfsh_single, benchmark_bfish_single, BENCHMARK_BLOWFISH_SINGLE); +BENCH_SCAN_SIMPLE(scan_bfsh_threads, benchmark_bfish_threads, BENCHMARK_BLOWFISH_THREADS); +BENCH_SCAN_SIMPLE(scan_bfsh_cores, benchmark_bfish_cores, BENCHMARK_BLOWFISH_CORES);  BENCH_SCAN_SIMPLE(scan_cryptohash, benchmark_cryptohash, BENCHMARK_CRYPTOHASH);  BENCH_SCAN_SIMPLE(scan_fib, benchmark_fib, BENCHMARK_FIB);  BENCH_SCAN_SIMPLE(scan_zlib, benchmark_zlib, BENCHMARK_ZLIB); @@ -71,7 +75,9 @@ void scan_gui(gboolean reload)  }  static ModuleEntry entries[] = { -    {N_("CPU Blowfish"), "blowfish.png", callback_bfsh, scan_bfsh, MODULE_FLAG_NONE}, +    {N_("CPU Blowfish (Single-thread)"), "blowfish.png", callback_bfsh_single, scan_bfsh_single, MODULE_FLAG_NONE}, +    {N_("CPU Blowfish (Multi-thread)"), "blowfish.png", callback_bfsh_threads, scan_bfsh_threads, MODULE_FLAG_NONE}, +    {N_("CPU Blowfish (Multi-core)"), "blowfish.png", callback_bfsh_cores, scan_bfsh_cores, 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}, @@ -90,13 +96,15 @@ const gchar *hi_note_func(gint entry)      case BENCHMARK_CRYPTOHASH:          return _("Results in MiB/second. Higher is better."); +    case BENCHMARK_BLOWFISH_SINGLE: +    case BENCHMARK_BLOWFISH_THREADS: +    case BENCHMARK_BLOWFISH_CORES:      case BENCHMARK_ZLIB:      case BENCHMARK_GUI:          return _("Results in HIMarks. Higher is better.");      case BENCHMARK_FFT:      case BENCHMARK_RAYTRACE: -    case BENCHMARK_BLOWFISH:      case BENCHMARK_FIB:      case BENCHMARK_NQUEENS:          return _("Results in seconds. Lower is better."); diff --git a/modules/benchmark/blowfish.c b/modules/benchmark/blowfish.c index 2aa11a2a..f8d2e14a 100644 --- a/modules/benchmark/blowfish.c +++ b/modules/benchmark/blowfish.c @@ -491,48 +491,3 @@ void Blowfish_Init(BLOWFISH_CTX * ctx, unsigned char *key, int keyLen)  	}      }  } - -static gpointer -parallel_blowfish(unsigned int start, unsigned int end, void *data, gint thread_number) -{ -    BLOWFISH_CTX ctx; -    unsigned int i; -    unsigned long L, R; - -    L = 0xBEBACAFE; -    R = 0xDEADBEEF; - -    for (i = start; i <= end; i++) { -        Blowfish_Init(&ctx, (unsigned char*)data, 65536); -        Blowfish_Encrypt(&ctx, &L, &R); -        Blowfish_Decrypt(&ctx, &L, &R); -    } - -    return NULL; -} - -void -benchmark_fish(void) -{ -    bench_value r = EMPTY_BENCH_VALUE; - -    gchar *tmpsrc; -    gchar *bdata_path; - -    bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL); -    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { -        bench_results[BENCHMARK_BLOWFISH] = r; -        g_free(bdata_path); -        return; -    } - -    shell_view_set_enabled(FALSE); -    shell_status_update("Performing Blowfish benchmark..."); - -    r = benchmark_parallel_for(0, 0, 50000, parallel_blowfish, tmpsrc); -    r.result = r.elapsed_time; - -    bench_results[BENCHMARK_BLOWFISH] = r; -    g_free(bdata_path); -    g_free(tmpsrc); -} diff --git a/modules/benchmark/blowfish2.c b/modules/benchmark/blowfish2.c new file mode 100644 index 00000000..c6ad78a8 --- /dev/null +++ b/modules/benchmark/blowfish2.c @@ -0,0 +1,86 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-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 "hardinfo.h" +#include "benchmark.h" +#include "blowfish.h" + +#define CRUNCH_TIME 7 + +/* must be less than or equal to + * file size of ( params.path_data + "benchmark.data" ) */ +#define BENCH_DATA_SIZE 65536 + +static gpointer bfish_exec(void *in_data, gint thread_number) +{ +    unsigned char key[] = "Has my shampoo arrived?"; +    unsigned char *data = NULL; +    unsigned long data_len = BENCH_DATA_SIZE, i = 0; +    BLOWFISH_CTX ctx; + +    data = malloc(BENCH_DATA_SIZE); +    memcpy(data, in_data, BENCH_DATA_SIZE); + +    Blowfish_Init(&ctx, key, strlen(key)); +    for(i = 0; i < data_len; i += 8) { +        Blowfish_Encrypt(&ctx, (unsigned long*)&data[i], (unsigned long*)&data[i+4]); +    } +    for(i = 0; i < data_len; i += 8) { +        Blowfish_Decrypt(&ctx, (unsigned long*)&data[i], (unsigned long*)&data[i+4]); +    } + +    free(data); +    return NULL; +} + +static gchar *get_data() +{ +    gchar *tmpsrc, *bdata_path; +    gsize length; + +    bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL); +    if (!g_file_get_contents(bdata_path, &tmpsrc, &length, NULL)) { +        g_free(bdata_path); +        return NULL; +    } +    if (length < BENCH_DATA_SIZE) { +        g_free(tmpsrc); +        return NULL; +    } + +    return tmpsrc; +} + +void benchmark_bfish_do(int threads, int entry, const char *status) +{ +    bench_value r = EMPTY_BENCH_VALUE; +    gchar *test_data = get_data(); + +    shell_view_set_enabled(FALSE); +    shell_status_update(status); + +    r = benchmark_crunch_for(CRUNCH_TIME, threads, bfish_exec, test_data); +    r.result /= 100; +    bench_results[entry] = r; + +    g_free(test_data); +} + +void benchmark_bfish_threads(void) { benchmark_bfish_do(0, BENCHMARK_BLOWFISH_THREADS, "Performing Blowfish benchmark (multi-thread)..."); } +void benchmark_bfish_single(void) { benchmark_bfish_do(1, BENCHMARK_BLOWFISH_SINGLE, "Performing Blowfish benchmark (single-thread)..."); } +void benchmark_bfish_cores(void) { benchmark_bfish_do(-1, BENCHMARK_BLOWFISH_CORES, "Performing Blowfish benchmark (multi-core)..."); } | 
