summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2019-08-10 23:11:21 -0500
committerLeandro A. F. Pereira <leandro@hardinfo.org>2019-08-14 20:02:42 -0700
commitd17909c82b03ad0427a285c66766421751546c42 (patch)
tree485588a0822984d437fcd22ed9f23f441760ca72
parent30508a10bf269e5ca06226fb50c86f5249cc746a (diff)
Benchmark: fixes, user_note, verifiable test data
* fix zlib display order * fix cryptohash MiB/s calculation * revision and params for other benchmarks * allow attaching user note to bench result with -u * don't inlcude the new result value bits if they are empty/invalid in bench_value_to_str(). bench_value_from_str() doesn't need to be modified. * bench_results: clean old result cpu name for x86 * use problem_marker() from dmi_memory to mark old version bench results * benchmark: verifiable test data size and content - The test data benchmark.data is stored in a file that could be edited to change the size or content. /* to guarantee size */ gchar *get_test_data(gsize min_size); /* to checksum content */ char *md5_digest_str(const char *data, unsigned int len); Signed-off-by: Burt P <pburt0@gmail.com>
-rw-r--r--CMakeLists.txt6
-rw-r--r--hardinfo/gg_key_file_parse_string_as_value.c4
-rw-r--r--hardinfo/info.c2
-rw-r--r--hardinfo/problem_marker.c13
-rw-r--r--hardinfo/util.c17
-rw-r--r--includes/benchmark.h10
-rw-r--r--includes/hardinfo.h8
-rw-r--r--modules/benchmark.c58
-rw-r--r--modules/benchmark/bench_results.c19
-rw-r--r--modules/benchmark/bench_util.c58
-rw-r--r--modules/benchmark/benches.c10
-rw-r--r--modules/benchmark/blowfish2.c47
-rw-r--r--modules/benchmark/cryptohash.c36
-rw-r--r--modules/benchmark/fft.c11
-rw-r--r--modules/benchmark/fib.c9
-rw-r--r--modules/benchmark/nqueens.c24
-rw-r--r--modules/benchmark/raytrace.c8
-rw-r--r--modules/benchmark/zlib.c63
-rw-r--r--modules/devices/dmi_memory.c9
19 files changed, 270 insertions, 142 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ef4f8a9f..309614f7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -173,6 +173,7 @@ set(MODULE_network_SOURCES
)
set(MODULE_benchmark_SOURCES_GTKANY
modules/benchmark.c
+ modules/benchmark/bench_util.c
modules/benchmark/blowfish.c
modules/benchmark/blowfish2.c
modules/benchmark/cryptohash.c
@@ -208,6 +209,7 @@ set_source_files_properties(
set_source_files_properties(
modules/devices/dmi_memory.c
# modules/devices/spd-decode.c
+ hardinfo/problem_marker.c
PROPERTIES
COMPILE_FLAGS "-std=c99 -Wall -Wextra -Wno-unused-function -Wno-deprecated-declarations -Wno-switch"
)
@@ -266,6 +268,8 @@ add_executable(hardinfo
hardinfo/hardinfo.c
hardinfo/socket.c
hardinfo/util.c
+ hardinfo/gg_key_file_parse_string_as_value.c
+ hardinfo/problem_marker.c
hardinfo/vendor.c
hardinfo/info.c
hardinfo/cpu_util.c
@@ -302,6 +306,8 @@ add_executable(hardinfo
hardinfo/hardinfo.c
hardinfo/socket.c
hardinfo/util.c
+ hardinfo/gg_key_file_parse_string_as_value.c
+ hardinfo/problem_marker.c
hardinfo/vendor.c
hardinfo/info.c
hardinfo/cpu_util.c
diff --git a/hardinfo/gg_key_file_parse_string_as_value.c b/hardinfo/gg_key_file_parse_string_as_value.c
index 496b1d35..7e871bc1 100644
--- a/hardinfo/gg_key_file_parse_string_as_value.c
+++ b/hardinfo/gg_key_file_parse_string_as_value.c
@@ -21,7 +21,9 @@
* along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-static gchar *
+#include <glib.h>
+
+gchar *
gg_key_file_parse_string_as_value (const gchar *string, const gchar list_separator)
{
gchar *value, *p, *q;
diff --git a/hardinfo/info.c b/hardinfo/info.c
index cf6af9f9..5f108814 100644
--- a/hardinfo/info.c
+++ b/hardinfo/info.c
@@ -23,7 +23,7 @@
* from GLib in flatten(), to escape characters and the separator.
* The function is not public in GLib and we don't have a GKeyFile
* to pass it anyway. */
-#include "gg_key_file_parse_string_as_value.c"
+/* Now in hardinfo.h -- #include "gg_key_file_parse_string_as_value.c" */
static const gchar *info_column_titles[] = {
"TextValue", "Value", "Progress", "Extra1", "Extra2"
diff --git a/hardinfo/problem_marker.c b/hardinfo/problem_marker.c
new file mode 100644
index 00000000..1e0c2aed
--- /dev/null
+++ b/hardinfo/problem_marker.c
@@ -0,0 +1,13 @@
+
+#include "hardinfo.h"
+
+/* requires COMPILE_FLAGS "-std=c99" */
+
+const char *problem_marker() {
+ static const char as_markup[] = "<big><b>\u26A0</b></big>";
+ static const char as_text[] = "(!)";
+ if (params.markup_ok)
+ return as_markup;
+ else
+ return as_text;
+}
diff --git a/hardinfo/util.c b/hardinfo/util.c
index e690ff20..764415df 100644
--- a/hardinfo/util.c
+++ b/hardinfo/util.c
@@ -393,6 +393,7 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param)
static gchar *report_format = NULL;
static gchar *run_benchmark = NULL;
static gchar *result_format = NULL;
+ static gchar *bench_user_note = NULL;
static gchar **use_modules = NULL;
static gint max_bench_results = 10;
@@ -416,6 +417,12 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param)
.arg_data = &run_benchmark,
.description = N_("run benchmark; requires benchmark.so to be loaded")},
{
+ .long_name = "user-note",
+ .short_name = 'u',
+ .arg = G_OPTION_ARG_STRING,
+ .arg_data = &bench_user_note,
+ .description = N_("note attached to benchmark results")},
+ {
.long_name = "result-format",
.short_name = 'g',
.arg = G_OPTION_ARG_STRING,
@@ -511,6 +518,14 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param)
param->report_format = REPORT_FORMAT_SHELL;
}
+ /* clean user note */
+ if (bench_user_note) {
+ char *p = NULL;
+ while(p = strchr(bench_user_note, ';')) { *p = ','; }
+ param->bench_user_note =
+ gg_key_file_parse_string_as_value(bench_user_note, '|');
+ }
+
/* html ok?
* gui: yes
* report html: yes
@@ -522,7 +537,7 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param)
gchar *confdir = g_build_filename(g_get_user_config_dir(), "hardinfo", NULL);
if (!g_file_test(confdir, G_FILE_TEST_EXISTS)) {
- mkdir(confdir, 0744);
+ mkdir(confdir, 0744);
}
g_free(confdir);
}
diff --git a/includes/benchmark.h b/includes/benchmark.h
index 04182944..8af3739b 100644
--- a/includes/benchmark.h
+++ b/includes/benchmark.h
@@ -2,6 +2,7 @@
#define __BENCHMARK_H__
#include "hardinfo.h"
+#include "util_sysobj.h" /* for SEQ() */
extern ProgramParameters params;
@@ -37,6 +38,7 @@ typedef struct {
int threads_used;
int revision;
char extra[256]; /* no \n, ; or | */
+ char user_note[256]; /* no \n, ; or | */
} bench_value;
#define EMPTY_BENCH_VALUE {-1.0f,0,0,-1,""}
@@ -58,4 +60,12 @@ bench_value benchmark_crunch_for(float seconds, gint n_threads,
extern bench_value bench_results[BENCHMARK_N_ENTRIES];
+/* in bench_util.c */
+
+/* guarantee a minimum size of data
+ * or return null */
+gchar *get_test_data(gsize min_size);
+char *md5_digest_str(const char *data, unsigned int len);
+#define bench_msg(msg, ...) fprintf (stderr, "[%s] " msg "\n", __FUNCTION__, ##__VA_ARGS__)
+
#endif /* __BENCHMARK_H__ */
diff --git a/includes/hardinfo.h b/includes/hardinfo.h
index ab9ecb55..cbbce468 100644
--- a/includes/hardinfo.h
+++ b/includes/hardinfo.h
@@ -70,6 +70,7 @@ struct _ProgramParameters {
gchar **use_modules;
gchar *run_benchmark;
+ gchar *bench_user_note;
gchar *result_format;
gchar *path_lib;
gchar *path_data;
@@ -185,6 +186,10 @@ gchar *moreinfo_lookup(gchar *key);
gboolean g_strv_contains(const gchar * const * strv, const gchar *str);
#endif
+/* in gg_key_file_parse_string_as_value.c */
+gchar *
+gg_key_file_parse_string_as_value (const gchar *string, const gchar list_separator);
+
/* Hardinfo labels that have # are truncated and/or hidden.
* Labels can't have $ because that is the delimiter in
* moreinfo.
@@ -201,4 +206,7 @@ gboolean hardinfo_spawn_command_line_sync(const gchar *command_line,
gint *exit_status,
GError **error);
+/* a marker in text to point out problems, using markup where possible */
+const char *problem_marker();
+
#endif /* __HARDINFO_H__ */
diff --git a/modules/benchmark.c b/modules/benchmark.c
index dc71be90..2448db00 100644
--- a/modules/benchmark.c
+++ b/modules/benchmark.c
@@ -29,6 +29,7 @@
#include <signal.h>
#include "benchmark.h"
+#include "appf.h"
#include "benchmark/bench_results.c"
@@ -44,16 +45,26 @@ static gchar *benchmark_include_results(bench_value result, const gchar * benchm
static gboolean sending_benchmark_results = FALSE;
char *bench_value_to_str(bench_value r) {
- return g_strdup_printf("%lf; %lf; %d; %d; %s", r.result, r.elapsed_time, r.threads_used, r.revision, r.extra);
+ gboolean has_rev = r.revision >= 0;
+ gboolean has_extra = r.extra && *r.extra != 0;
+ gboolean has_user_note = r.user_note && *r.user_note != 0;
+ char *ret = g_strdup_printf("%lf; %lf; %d", r.result, r.elapsed_time, r.threads_used);
+ if (has_rev || has_extra || has_user_note)
+ ret = appf(ret, "; ", "%d", r.revision);
+ if (has_extra || has_user_note)
+ ret = appf(ret, "; ", "%s", r.extra);
+ if (has_user_note)
+ ret = appf(ret, "; ", "%s", r.user_note);
+ return ret;
}
bench_value bench_value_from_str(const char* str) {
bench_value ret = EMPTY_BENCH_VALUE;
double r, e;
int t, c, v;
- char extra[256];
+ char extra[256], user_note[256];
if (str) {
- c = sscanf(str, "%lf; %lf; %d; %d; %255[^\r\n;|]", &r, &e, &t, &v, extra);
+ c = sscanf(str, "%lf; %lf; %d; %d; %255[^\r\n;|]; %255[^\r\n;|]", &r, &e, &t, &v, extra, user_note);
if (c >= 3) {
ret.result = r;
ret.elapsed_time = e;
@@ -65,6 +76,9 @@ bench_value bench_value_from_str(const char* str) {
if (c >= 5) {
strcpy(ret.extra, extra);
}
+ if (c >= 6) {
+ strcpy(ret.user_note, user_note);
+ }
}
return ret;
}
@@ -279,32 +293,6 @@ bench_value benchmark_parallel_for(gint n_threads, guint start, guint end,
return ret;
}
-static gchar *clean_cpuname(gchar *cpuname)
-{
- gchar *ret = NULL, *tmp;
- gchar *remove[] = {
- "(R)", "(r)", "(TM)", "(tm)", "Processor",
- "Technology", "processor", "CPU",
- "cpu", "Genuine", "Authentic", NULL
- };
- gint i;
-
- ret = g_strdup(cpuname);
- for (i = 0; remove[i]; i++) {
- tmp = strreplace(ret, remove[i], "");
- g_free(ret);
- ret = tmp;
- }
-
- ret = strend(ret, '@');
- ret = g_strstrip(ret);
-
- tmp = g_strdup(ret);
- g_free(ret);
-
- return tmp;
-}
-
gchar *hi_more_info(gchar * entry)
{
gchar *info = moreinfo_lookup_with_prefix("BENCH", entry);
@@ -328,8 +316,9 @@ static void br_mi_add(char **results_list, bench_result *b, gboolean select) {
ckey = hardinfo_clean_label(b->machine->cpu_name, 0);
rkey = g_strdup_printf("%s__%d", b->machine->mid, ri++);
- *results_list = h_strdup_cprintf("$%s%s$%s=%.2f|%s\n", *results_list,
+ *results_list = h_strdup_cprintf("$%s%s$%s%s=%.2f|%s\n", *results_list,
select ? "*" : "", rkey, ckey,
+ b->legacy ? problem_marker() : "",
b->bvalue.result, b->machine->cpu_config);
moreinfo_add_with_prefix("BENCH", rkey, bench_result_more_info(b) );
@@ -490,6 +479,9 @@ static gboolean do_benchmark_handler(GIOChannel *source,
}
r = bench_value_from_str(result);
+ /* attach a user note */
+ if (params.bench_user_note)
+ strncpy(r.user_note, params.bench_user_note, 255);
bench_dialog->r = r;
gtk_widget_destroy(bench_dialog->dialog);
@@ -695,6 +687,10 @@ static gchar *run_benchmark(gchar *name)
#define CHK_RESULT_FORMAT(F) (params.result_format && strcmp(params.result_format, F) == 0)
if (params.run_benchmark) {
+ /* attach the user note */
+ if (params.bench_user_note)
+ strncpy(bench_results[i].user_note, params.bench_user_note, 255);
+
if (CHK_RESULT_FORMAT("conf") ) {
bench_result *b = bench_result_this_machine(name, bench_results[i]);
char *temp = bench_result_benchmarkconf_line(b);
@@ -706,7 +702,7 @@ static gchar *run_benchmark(gchar *name)
bench_result_free(b);
return temp;
}
- /* defaults to "short" which is below*/
+ /* defaults to "short" which is below */
}
return bench_value_to_str(bench_results[i]);
diff --git a/modules/benchmark/bench_results.c b/modules/benchmark/bench_results.c
index 3609a5dd..171285d1 100644
--- a/modules/benchmark/bench_results.c
+++ b/modules/benchmark/bench_results.c
@@ -334,6 +334,15 @@ bench_result *bench_result_benchmarkconf(const char *section, const char *key, c
/* old results only give threads */
b->machine->processors = -1;
b->machine->cores = -1;
+
+ /* clean the old result's CPU model name
+ * if it was probably an x86 */
+ if (strstr(b->machine->cpu_name, "Intel")
+ || strstr(b->machine->cpu_name, "AMD")
+ || strstr(b->machine->cpu_name, "VIA")
+ || strstr(b->machine->cpu_name, "Cyrix") ) {
+ nice_name_x86_cpuid_model_string(b->machine->cpu_name);
+ }
}
b->machine->cpu_config = cpu_config_retranslate(b->machine->cpu_config, 0, 1);
@@ -383,7 +392,8 @@ static char *bench_result_more_info_less(bench_result *b) {
/* elapsed */ "%s=%0.4f %s\n"
"%s=%s\n"
"%s=%s\n"
- /* legacy */ "%s=%s\n"
+ "%s=%s\n"
+ /* legacy */ "%s%s=%s\n"
"[%s]\n"
/* board */ "%s=%s\n"
/* cpu */ "%s=%s\n"
@@ -398,6 +408,8 @@ static char *bench_result_more_info_less(bench_result *b) {
_("Elapsed Time"), b->bvalue.elapsed_time, _("seconds"),
*bench_str ? _("Revision") : _("#Revision"), bench_str,
*b->bvalue.extra ? _("Extra Information") : _("#Extra"), b->bvalue.extra,
+ *b->bvalue.user_note ? _("User Note") : _("#User Note"), b->bvalue.user_note,
+ b->legacy ? problem_marker() : "",
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"),
@@ -426,7 +438,8 @@ static char *bench_result_more_info_complete(bench_result *b) {
/* result */ "%s=%0.2f\n"
/* elapsed */ "%s=%0.4f %s\n"
"%s=%s\n"
- /* legacy */ "%s=%s\n"
+ "%s=%s\n"
+ /* legacy */ "%s%s=%s\n"
"[%s]\n"
/* board */ "%s=%s\n"
/* cpu */ "%s=%s\n"
@@ -445,6 +458,8 @@ static char *bench_result_more_info_complete(bench_result *b) {
_("Result"), b->bvalue.result,
_("Elapsed Time"), b->bvalue.elapsed_time, _("seconds"),
*b->bvalue.extra ? _("Extra Information") : _("#Extra"), b->bvalue.extra,
+ *b->bvalue.user_note ? _("User Note") : _("#User Note"), b->bvalue.user_note,
+ b->legacy ? problem_marker() : "",
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/bench_util.c b/modules/benchmark/bench_util.c
new file mode 100644
index 00000000..d9e5bc55
--- /dev/null
+++ b/modules/benchmark/bench_util.c
@@ -0,0 +1,58 @@
+
+#include "benchmark.h"
+#include "md5.h"
+
+gchar *get_test_data(gsize min_size) {
+ gchar *bdata_path, *data;
+ gsize data_size;
+
+ gchar *exp_data, *p;
+ gsize sz;
+
+ bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL);
+ if (!g_file_get_contents(bdata_path, &data, &data_size, NULL)) {
+ g_free(bdata_path);
+ return NULL;
+ }
+
+ if (data_size < min_size) {
+ DEBUG("expanding %lu bytes of test data to %lu bytes", data_size, min_size);
+ exp_data = g_malloc(min_size + 1);
+ memcpy(exp_data, data, data_size);
+ p = exp_data + data_size;
+ sz = data_size;
+ while (sz < (min_size - data_size) ) {
+ memcpy(p, data, data_size);
+ p += data_size;
+ sz += data_size;
+ }
+ strncpy(p, data, min_size - sz);
+ g_free(data);
+ data = exp_data;
+ }
+ g_free(bdata_path);
+
+ return data;
+}
+
+char *digest_to_str(const char *digest, int len) {
+ int max = len * 2;
+ char *ret = malloc(max+1);
+ char *p = ret;
+ memset(ret, 0, max+1);
+ int i = 0;
+ for(; i < len; i++) {
+ unsigned char byte = digest[i];
+ p += sprintf(p, "%02x", byte);
+ }
+ return ret;
+}
+
+char *md5_digest_str(const char *data, unsigned int len) {
+ struct MD5Context ctx;
+ guchar digest[16];
+ MD5Init(&ctx);
+ MD5Update(&ctx, (guchar *)data, len);
+ MD5Final(digest, &ctx);
+ return digest_to_str(digest, 16);
+}
diff --git a/modules/benchmark/benches.c b/modules/benchmark/benches.c
index 6343d95b..354757c1 100644
--- a/modules/benchmark/benches.c
+++ b/modules/benchmark/benches.c
@@ -26,16 +26,18 @@ gchar *CN() { \
return benchmark_include_results(bench_results[BID], BN); \
}
-BENCH_CALLBACK(callback_gui, "GPU Drawing", BENCHMARK_GUI, 1);
-BENCH_CALLBACK(callback_fft, "FPU FFT", BENCHMARK_FFT, 0);
+/* lower is better R = 0 */
+BENCH_CALLBACK(callback_fib, "CPU Fibonacci", BENCHMARK_FIB, 0);
BENCH_CALLBACK(callback_nqueens, "CPU N-Queens", BENCHMARK_NQUEENS, 0);
+BENCH_CALLBACK(callback_fft, "FPU FFT", BENCHMARK_FFT, 0);
BENCH_CALLBACK(callback_raytr, "FPU Raytracing", BENCHMARK_RAYTRACE, 0);
+/* higher is better R = 1 */
BENCH_CALLBACK(callback_bfsh_single, "CPU Blowfish (Single-thread)", BENCHMARK_BLOWFISH_SINGLE, 1);
BENCH_CALLBACK(callback_bfsh_threads, "CPU Blowfish (Multi-thread)", BENCHMARK_BLOWFISH_THREADS, 1);
BENCH_CALLBACK(callback_bfsh_cores, "CPU Blowfish (Multi-core)", BENCHMARK_BLOWFISH_CORES, 1);
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);
+BENCH_CALLBACK(callback_zlib, "CPU Zlib", BENCHMARK_ZLIB, 1);
+BENCH_CALLBACK(callback_gui, "GPU Drawing", BENCHMARK_GUI, 1);
#define BENCH_SCAN_SIMPLE(SN, BF, BID) \
void SN(gboolean reload) { \
diff --git a/modules/benchmark/blowfish2.c b/modules/benchmark/blowfish2.c
index c6ad78a8..5fe42b10 100644
--- a/modules/benchmark/blowfish2.c
+++ b/modules/benchmark/blowfish2.c
@@ -20,15 +20,17 @@
#include "benchmark.h"
#include "blowfish.h"
+/* if anything changes in this block, increment revision */
+#define BENCH_REVISION 1
#define CRUNCH_TIME 7
-
-/* must be less than or equal to
- * file size of ( params.path_data + "benchmark.data" ) */
#define BENCH_DATA_SIZE 65536
+#define BENCH_DATA_MD5 "c25cf5c889f7bead2ff39788eedae37b"
+#define BLOW_KEY "Has my shampoo arrived?"
+#define BLOW_KEY_MD5 "6eac709cca51a228bfa70150c9c5a7c4"
-static gpointer bfish_exec(void *in_data, gint thread_number)
+static gpointer bfish_exec(const void *in_data, gint thread_number)
{
- unsigned char key[] = "Has my shampoo arrived?";
+ unsigned char key[] = BLOW_KEY;
unsigned char *data = NULL;
unsigned long data_len = BENCH_DATA_SIZE, i = 0;
BLOWFISH_CTX ctx;
@@ -48,37 +50,32 @@ static gpointer bfish_exec(void *in_data, gint thread_number)
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();
+ gchar *test_data = get_test_data(BENCH_DATA_SIZE);
+ if (!test_data) return;
shell_view_set_enabled(FALSE);
shell_status_update(status);
+ gchar *k = md5_digest_str(BLOW_KEY, strlen(BLOW_KEY));
+ if (!SEQ(k, BLOW_KEY_MD5))
+ bench_msg("test key has different md5sum: expected %s, actual %s", BLOW_KEY_MD5, k);
+ gchar *d = md5_digest_str(test_data, BENCH_DATA_SIZE);
+ if (!SEQ(d, BENCH_DATA_MD5))
+ bench_msg("test data has different md5sum: expected %s, actual %s", BENCH_DATA_MD5, d);
+
r = benchmark_crunch_for(CRUNCH_TIME, threads, bfish_exec, test_data);
r.result /= 100;
- bench_results[entry] = r;
+ r.revision = BENCH_REVISION;
+ snprintf(r.extra, 255, "%0.1fs, k:%s, d:%s", (double)CRUNCH_TIME, k, d);
g_free(test_data);
+ g_free(k);
+ g_free(d);
+
+ bench_results[entry] = r;
}
void benchmark_bfish_threads(void) { benchmark_bfish_do(0, BENCHMARK_BLOWFISH_THREADS, "Performing Blowfish benchmark (multi-thread)..."); }
diff --git a/modules/benchmark/cryptohash.c b/modules/benchmark/cryptohash.c
index 6150f3ef..cf6f998e 100644
--- a/modules/benchmark/cryptohash.c
+++ b/modules/benchmark/cryptohash.c
@@ -20,6 +20,15 @@
#include "sha1.h"
#include "benchmark.h"
+/* if anything changes in this block, increment revision */
+#define BENCH_REVISION 1
+#define BENCH_DATA_SIZE 65536
+#define BENCH_DATA_MD5 "c25cf5c889f7bead2ff39788eedae37b"
+#define STEPS 5000
+#define CALC_MBs(r) (STEPS*BENCH_DATA_SIZE)/(1024*1024)/r
+/* 5000*65536/(1024*1024) = 312.5 -- old version used 312.0 so results
+ * don't exactly compare. */
+
void inline md5_step(char *data, glong srclen)
{
struct MD5Context ctx;
@@ -46,9 +55,9 @@ static gpointer cryptohash_for(unsigned int start, unsigned int end, void *data,
for (i = start; i <= end; i++) {
if (i & 1) {
- md5_step(data, 65536);
+ md5_step(data, BENCH_DATA_SIZE);
} else {
- sha1_step(data, 65536);
+ sha1_step(data, BENCH_DATA_SIZE);
}
}
@@ -59,22 +68,23 @@ void
benchmark_cryptohash(void)
{
bench_value r = EMPTY_BENCH_VALUE;
- 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;
- }
+ gchar *test_data = get_test_data(BENCH_DATA_SIZE);
+ if (!test_data) return;
shell_view_set_enabled(FALSE);
shell_status_update("Running CryptoHash benchmark...");
- r = benchmark_parallel_for(0, 0, 5000, cryptohash_for, tmpsrc);
+ gchar *d = md5_digest_str(test_data, BENCH_DATA_SIZE);
+ if (!SEQ(d, BENCH_DATA_MD5))
+ bench_msg("test data has different md5sum: expected %s, actual %s", BENCH_DATA_MD5, d);
+
+ r = benchmark_parallel_for(0, 0, STEPS, cryptohash_for, test_data);
+ r.revision = BENCH_REVISION;
+ snprintf(r.extra, 255, "r:%d, d:%s", STEPS, d);
- g_free(bdata_path);
- g_free(tmpsrc);
+ g_free(test_data);
+ g_free(d);
- r.result = 312.0 / r.elapsed_time; //TODO: explain in code comments
+ r.result = CALC_MBs(r.elapsed_time);
bench_results[BENCHMARK_CRYPTOHASH] = r;
}
diff --git a/modules/benchmark/fft.c b/modules/benchmark/fft.c
index caa52d3d..b4bff39b 100644
--- a/modules/benchmark/fft.c
+++ b/modules/benchmark/fft.c
@@ -20,6 +20,10 @@
#include "benchmark.h"
#include "fftbench.h"
+/* if anything changes in this block, increment revision */
+#define BENCH_REVISION -1
+#define FFT_MAXT 4
+
static gpointer fft_for(unsigned int start, unsigned int end, void *data, gint thread_number)
{
unsigned int i;
@@ -33,8 +37,6 @@ static gpointer fft_for(unsigned int start, unsigned int end, void *data, gint t
return NULL;
}
-#define FFT_MAXT 4
-
void
benchmark_fft(void)
{
@@ -50,7 +52,7 @@ benchmark_fft(void)
/* Pre-allocate all benchmarks */
benches = g_new0(FFTBench *, FFT_MAXT);
for (i = 0; i < FFT_MAXT; i++) {
- benches[i] = fft_bench_new();
+ benches[i] = fft_bench_new();
}
/* Run the benchmark */
@@ -58,10 +60,11 @@ benchmark_fft(void)
/* Free up the memory */
for (i = 0; i < FFT_MAXT; i++) {
- fft_bench_free(benches[i]);
+ fft_bench_free(benches[i]);
}
g_free(benches);
r.result = r.elapsed_time;
+ r.revision = BENCH_REVISION;
bench_results[BENCHMARK_FFT] = r;
}
diff --git a/modules/benchmark/fib.c b/modules/benchmark/fib.c
index d75ac367..5648b406 100644
--- a/modules/benchmark/fib.c
+++ b/modules/benchmark/fib.c
@@ -18,6 +18,10 @@
#include "benchmark.h"
+/* if anything changes in this block, increment revision */
+#define BENCH_REVISION 0
+#define ANSWER 42
+
gulong fib(gulong n)
{
if (n == 0)
@@ -39,7 +43,7 @@ benchmark_fib(void)
g_timer_reset(timer);
g_timer_start(timer);
- fib(42);
+ fib(ANSWER);
g_timer_stop(timer);
r.elapsed_time = g_timer_elapsed(timer, NULL);
@@ -48,5 +52,8 @@ benchmark_fib(void)
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;
}
diff --git a/modules/benchmark/nqueens.c b/modules/benchmark/nqueens.c
index 78293abb..a26aa70a 100644
--- a/modules/benchmark/nqueens.c
+++ b/modules/benchmark/nqueens.c
@@ -9,29 +9,29 @@
#include "hardinfo.h"
#include "benchmark.h"
+/* if anything changes in this block, increment revision */
+#define BENCH_REVISION 0
#define QUEENS 11
int row[QUEENS];
-bool safe(int x, int y)
-{
+bool safe(int x, int y) {
int i;
for (i = 1; i <= y; i++)
- if (row[y - i] == x || row[y - i] == x - i || row[y - i] == x + i)
- return false;
+ if (row[y - i] == x || row[y - i] == x - i || row[y - i] == x + i)
+ return false;
return true;
}
-int nqueens(int y)
-{
+int nqueens(int y) {
int x;
for (x = 0; x < QUEENS; x++) {
- if (safe((row[y - 1] = x), y - 1)) {
- if (y < QUEENS) {
- nqueens(y + 1);
- } else {
- break;
+ if (safe((row[y - 1] = x), y - 1)) {
+ if (y < QUEENS) {
+ nqueens(y + 1);
+ } else {
+ break;
}
}
}
@@ -60,6 +60,8 @@ benchmark_nqueens(void)
r = benchmark_parallel_for(0, 0, 10, nqueens_for, NULL);
r.result = r.elapsed_time;
+ r.revision = BENCH_REVISION;
+ snprintf(r.extra, 255, "q:%d", QUEENS);
bench_results[BENCHMARK_NQUEENS] = r;
}
diff --git a/modules/benchmark/raytrace.c b/modules/benchmark/raytrace.c
index c7963583..33ca5df3 100644
--- a/modules/benchmark/raytrace.c
+++ b/modules/benchmark/raytrace.c
@@ -18,6 +18,10 @@
#include "benchmark.h"
+/* if anything changes in this block, increment revision */
+#define BENCH_REVISION 0
+#define STEPS 1000
+
void fbench(); /* fbench.c */
static gpointer
@@ -40,8 +44,10 @@ benchmark_raytrace(void)
shell_view_set_enabled(FALSE);
shell_status_update("Performing John Walker's FBENCH...");
- r = benchmark_parallel_for(0, 0, 1000, parallel_raytrace, NULL);
+ r = benchmark_parallel_for(0, 0, STEPS, parallel_raytrace, NULL);
r.result = r.elapsed_time;
+ r.revision = BENCH_REVISION;
+ snprintf(r.extra, 255, "r:%d", STEPS);
bench_results[BENCHMARK_RAYTRACE] = r;
}
diff --git a/modules/benchmark/zlib.c b/modules/benchmark/zlib.c
index ce6a0048..b19f3c9f 100644
--- a/modules/benchmark/zlib.c
+++ b/modules/benchmark/zlib.c
@@ -24,8 +24,15 @@
/* zip/unzip 256KB blocks for 7 seconds
* result is number of full completions / 100 */
+
+/* if anything changes in this block, increment revision */
+#define BENCH_REVISION 3
#define BENCH_DATA_SIZE 262144
+#define BENCH_DATA_MD5 "3753b649c4fa9ea4576fc8f89a773de2"
#define CRUNCH_TIME 7
+#define VERIFY_RESULT 1
+
+static unsigned int zlib_errors = 0;
static gpointer zlib_for(void *in_data, gint thread_number) {
char *compressed;
@@ -42,60 +49,40 @@ static gpointer zlib_for(void *in_data, gint thread_number) {
compress(compressed, &compressedBound, in_data, BENCH_DATA_SIZE);
uncompress(uncompressed, &destBound, compressed, compressedBound);
+ if (VERIFY_RESULT) {
+ int cr = memcmp(in_data, uncompressed, BENCH_DATA_SIZE);
+ if (!!cr) {
+ zlib_errors++;
+ bench_msg("zlib error: uncompressed != original");
+ }
+ }
free(compressed);
return NULL;
}
-static gchar *get_test_data(gsize min_size) {
- gchar *bdata_path, *data;
- gsize data_size;
-
- gchar *exp_data, *p;
- gsize sz;
-
- bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL);
- if (!g_file_get_contents(bdata_path, &data, &data_size, NULL)) {
- g_free(bdata_path);
- return NULL;
- }
-
- if (data_size < min_size) {
- DEBUG("expanding %lu bytes of test data to %lu bytes", data_size, min_size);
- exp_data = g_malloc(min_size + 1);
- memcpy(exp_data, data, data_size);
- p = exp_data + data_size;
- sz = data_size;
- while (sz < (min_size - data_size) ) {
- memcpy(p, data, data_size);
- p += data_size;
- sz += data_size;
- }
- strncpy(p, data, min_size - sz);
- g_free(data);
- data = exp_data;
- }
- g_free(bdata_path);
- return data;
-}
-
void
benchmark_zlib(void)
{
bench_value r = EMPTY_BENCH_VALUE;
- gchar *data = get_test_data(BENCH_DATA_SIZE);
- if (!data)
+ gchar *test_data = get_test_data(BENCH_DATA_SIZE);
+ if (!test_data)
return;
shell_view_set_enabled(FALSE);
shell_status_update("Running Zlib benchmark...");
- r = benchmark_crunch_for(CRUNCH_TIME, 0, zlib_for, data);
+ gchar *d = md5_digest_str(test_data, BENCH_DATA_SIZE);
+ if (!SEQ(d, BENCH_DATA_MD5))
+ bench_msg("test data has different md5sum: expected %s, actual %s", BENCH_DATA_MD5, d);
+
+ r = benchmark_crunch_for(CRUNCH_TIME, 0, zlib_for, test_data);
r.result /= 100;
- r.revision = 2;
- snprintf(r.extra, 255, "zlib %s (built against: %s)", zlib_version, ZLIB_VERSION);
+ r.revision = BENCH_REVISION;
+ snprintf(r.extra, 255, "zlib %s (built against: %s), d:%s, e:%d", zlib_version, ZLIB_VERSION, d, zlib_errors);
bench_results[BENCHMARK_ZLIB] = r;
- g_free(data);
+ g_free(test_data);
+ g_free(d);
}
diff --git a/modules/devices/dmi_memory.c b/modules/devices/dmi_memory.c
index 8e9e25c3..753c4c74 100644
--- a/modules/devices/dmi_memory.c
+++ b/modules/devices/dmi_memory.c
@@ -53,15 +53,6 @@ static const char empty_icon[] = "module.png";
#define UNKIFEMPTY2(f) ((*f) ? f : _("(Unknown)"))
#define STR_IGNORE(str, ignore) if (SEQ(str, ignore)) { *str = 0; null_if_empty(&str); }
-const char *problem_marker() {
- static const char as_markup[] = "<big><b>\u26A0</b></big>";
- static const char as_text[] = "(!)";
- if (params.markup_ok)
- return as_markup;
- else
- return as_text;
-}
-
dmi_mem_size dmi_read_memory_str_to_MiB(const char *memstr) {
dmi_mem_size ret = 0, v = 0;
char l[7] = "";