From 437e43308bc69e6d40d8252bd932276e2ba68a8e Mon Sep 17 00:00:00 2001
From: 05356787 <05356787@localhost.localdomain>
Date: Thu, 30 Oct 2008 08:48:41 -0200
Subject: Allow adding more information per column
---
hardinfo2/benchmark.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'hardinfo2/benchmark.c')
diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c
index f9d7926b..b1438fce 100644
--- a/hardinfo2/benchmark.c
+++ b/hardinfo2/benchmark.c
@@ -190,7 +190,7 @@ static gchar *__benchmark_include_results(gdouble result,
"ColumnTitle$TextValue=CPU\n"
"ShowColumnHeaders=true\n"
"[%s]\n"
- "This Machine=%.3f\n"
+ "This Machine=%.3f|extra1|extra2\n"
"%s", order_type, benchmark, result, results);
}
--
cgit v1.2.3
From 0fa6067111faa2ce69ed8275b06ef8d5ab669a56 Mon Sep 17 00:00:00 2001
From: 05356787 <05356787@localhost.localdomain>
Date: Thu, 30 Oct 2008 09:54:35 -0200
Subject: Cleanups
---
hardinfo2/benchmark.c | 33 ++++++++++++++++++---------------
hardinfo2/shell.c | 3 ++-
2 files changed, 20 insertions(+), 16 deletions(-)
(limited to 'hardinfo2/benchmark.c')
diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c
index b1438fce..79d3d2d4 100644
--- a/hardinfo2/benchmark.c
+++ b/hardinfo2/benchmark.c
@@ -150,7 +150,7 @@ static gchar *__benchmark_include_results(gdouble result,
{
GKeyFile *conf;
gchar **machines;
- gchar *path, *results = g_strdup("");
+ gchar *path, *results = g_strdup(""), *return_value, *processor_frequency;
int i;
conf = g_key_file_new();
@@ -178,22 +178,25 @@ static gchar *__benchmark_include_results(gdouble result,
g_free(path);
g_key_file_free(conf);
- DEBUG("results = %s", results);
-
- return g_strdup_printf("[$ShellParam$]\n"
- "Zebra=1\n"
- "OrderType=%d\n"
- "ViewType=3\n"
- "ColumnTitle$Extra1=CPU Clock\n"
- "ColumnTitle$Extra2=Memory\n"
- "ColumnTitle$Progress=Results\n"
- "ColumnTitle$TextValue=CPU\n"
- "ShowColumnHeaders=true\n"
- "[%s]\n"
- "This Machine=%.3f|extra1|extra2\n"
- "%s", order_type, benchmark, result, results);
+ processor_frequency = module_call_method("devices::getProcessorFrequency");
+ return_value = g_strdup_printf("[$ShellParam$]\n"
+ "Zebra=1\n"
+ "OrderType=%d\n"
+ "ViewType=3\n"
+ "ColumnTitle$Extra1=CPU Clock\n"
+ "ColumnTitle$Extra2=Memory\n"
+ "ColumnTitle$Progress=Results\n"
+ "ColumnTitle$TextValue=CPU\n"
+ "ShowColumnHeaders=true\n"
+ "[%s]\n"
+ "This Machine=%.3f|%s MHz|extra2\n"
+ "%s", order_type, benchmark, result, processor_frequency, results);
+ g_free(processor_frequency);
+ return return_value;
}
+
+
static gchar *benchmark_include_results_reverse(gdouble result,
const gchar * benchmark)
{
diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c
index 2a61246b..6d0508c7 100644
--- a/hardinfo2/shell.c
+++ b/hardinfo2/shell.c
@@ -1107,9 +1107,10 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload)
store = GTK_TREE_STORE(shell->info->model);
+ gdk_window_freeze_updates(shell->window->window);
+
g_object_ref(shell->info->model);
gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info->view), NULL);
- gdk_window_freeze_updates(shell->window->window);
gtk_tree_store_clear(store);
--
cgit v1.2.3
From 7e3e159cd7b0f12e6a3a5bf675334791ee83c6c3 Mon Sep 17 00:00:00 2001
From: Leandro Pereira
Date: Thu, 30 Oct 2008 14:27:42 -0200
Subject: Fuse MD5 and SHA1 benchmark into one
---
hardinfo2/arch/common/cryptohash.h | 78 ++++++++++++++++++++++++++++++++++++++
hardinfo2/arch/common/md5.h | 63 ------------------------------
hardinfo2/arch/common/sha1.h | 62 ------------------------------
hardinfo2/benchmark.c | 41 ++++++--------------
4 files changed, 89 insertions(+), 155 deletions(-)
create mode 100644 hardinfo2/arch/common/cryptohash.h
delete mode 100644 hardinfo2/arch/common/md5.h
delete mode 100644 hardinfo2/arch/common/sha1.h
(limited to 'hardinfo2/benchmark.c')
diff --git a/hardinfo2/arch/common/cryptohash.h b/hardinfo2/arch/common/cryptohash.h
new file mode 100644
index 00000000..9897bb6b
--- /dev/null
+++ b/hardinfo2/arch/common/cryptohash.h
@@ -0,0 +1,78 @@
+/*
+ * HardInfo - Displays System Information
+ * Copyright (C) 2003-2007 Leandro A. F. Pereira
+ *
+ * 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
+#include
+
+static void inline md5_step(char *data, glong srclen)
+{
+ struct MD5Context ctx;
+ guchar checksum[16];
+
+ MD5Init(&ctx);
+ MD5Update(&ctx, (guchar *)data, srclen);
+ MD5Final(checksum, &ctx);
+}
+
+static void inline sha1_step(char *data, glong srclen)
+{
+ SHA1_CTX ctx;
+ guchar checksum[20];
+
+ SHA1Init(&ctx);
+ SHA1Update(&ctx, (guchar*)data, srclen);
+ SHA1Final(checksum, &ctx);
+}
+
+static gpointer cryptohash_for(unsigned int start, unsigned int end, void *data, GTimer *timer)
+{
+ unsigned int i;
+
+ for (i = start; i <= end; i++) {
+ if (i % 2 == 0) {
+ md5_step(data, 65536);
+ } else {
+ sha1_step(data, 65536);
+ }
+ }
+
+ return NULL;
+}
+
+static void
+benchmark_cryptohash(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 CryptoHash benchmark...");
+
+ elapsed = benchmark_parallel_for(0, 5000, cryptohash_for, tmpsrc);
+
+ g_free(bdata_path);
+ g_free(tmpsrc);
+
+ bench_results[BENCHMARK_CRYPTOHASH] = 312.0 / elapsed;
+}
diff --git a/hardinfo2/arch/common/md5.h b/hardinfo2/arch/common/md5.h
deleted file mode 100644
index d839778a..00000000
--- a/hardinfo2/arch/common/md5.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * HardInfo - Displays System Information
- * Copyright (C) 2003-2007 Leandro A. F. Pereira
- *
- * 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
-
-static void
-benchmark_md5(void)
-{
- struct MD5Context ctx;
- guchar checksum[16];
- int i;
- GTimer *timer = g_timer_new();
- gdouble elapsed = 0;
- gchar src[65536], *tmpsrc;
- glong srclen = 65536;
-
- tmpsrc = src;
-
- gchar *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("Generating MD5 sum for 312MiB of data...");
-
- for (i = 0; i <= 5000; i++) {
- g_timer_start(timer);
-
- MD5Init(&ctx);
- MD5Update(&ctx, (guchar*)tmpsrc, srclen);
- MD5Final(checksum, &ctx);
-
- g_timer_stop(timer);
- elapsed += g_timer_elapsed(timer, NULL);
-
- shell_status_set_percentage(i/50);
- }
-
- g_timer_destroy(timer);
- g_free(bdata_path);
-
- bench_results[BENCHMARK_MD5] = 312.0 / elapsed;
-}
-
diff --git a/hardinfo2/arch/common/sha1.h b/hardinfo2/arch/common/sha1.h
deleted file mode 100644
index c506375b..00000000
--- a/hardinfo2/arch/common/sha1.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * HardInfo - Displays System Information
- * Copyright (C) 2003-2007 Leandro A. F. Pereira
- *
- * 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
-
-static void
-benchmark_sha1(void)
-{
- SHA1_CTX ctx;
- guchar checksum[20];
- int i;
- GTimer *timer = g_timer_new();
- gdouble elapsed = 0;
- gchar src[65536], *tmpsrc;
- glong srclen = 65536;
-
- tmpsrc = src;
-
- gchar *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("Generating SHA1 sum for 312MiB of data...");
-
- for (i = 0; i <= 5000; i++) {
- g_timer_start(timer);
-
- SHA1Init(&ctx);
- SHA1Update(&ctx, (guchar*)tmpsrc, srclen);
- SHA1Final(checksum, &ctx);
-
- g_timer_stop(timer);
- elapsed += g_timer_elapsed(timer, NULL);
-
- shell_status_set_percentage(i/50);
- }
-
- g_timer_destroy(timer);
- g_free(bdata_path);
-
- bench_results[BENCHMARK_SHA1] = 312.0 / elapsed;
-}
-
diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c
index 79d3d2d4..6ab1a8af 100644
--- a/hardinfo2/benchmark.c
+++ b/hardinfo2/benchmark.c
@@ -28,8 +28,7 @@
enum {
BENCHMARK_ZLIB,
BENCHMARK_FIB,
- BENCHMARK_MD5,
- BENCHMARK_SHA1,
+ BENCHMARK_CRYPTOHASH,
BENCHMARK_BLOWFISH,
BENCHMARK_RAYTRACE,
BENCHMARK_N_ENTRIES
@@ -38,22 +37,19 @@ enum {
void scan_zlib(gboolean reload);
void scan_raytr(gboolean reload);
void scan_bfsh(gboolean reload);
-void scan_md5(gboolean reload);
+void scan_cryptohash(gboolean reload);
void scan_fib(gboolean reload);
-void scan_sha1(gboolean reload);
gchar *callback_zlib();
gchar *callback_raytr();
gchar *callback_bfsh();
-gchar *callback_md5();
gchar *callback_fib();
-gchar *callback_sha1();
+gchar *callback_cryptohash();
static ModuleEntry entries[] = {
{"CPU ZLib", "compress.png", callback_zlib, scan_zlib},
{"CPU Fibonacci", "module.png", callback_fib, scan_fib},
- {"CPU MD5", "module.png", callback_md5, scan_md5},
- {"CPU SHA1", "module.png", callback_sha1, scan_sha1},
+ {"CPU CryptoHash", "module.png", callback_cryptohash, scan_cryptohash},
{"CPU Blowfish", "blowfish.png", callback_bfsh, scan_bfsh},
{"FPU Raytracing", "raytrace.png", callback_raytr, scan_raytr},
{NULL}
@@ -215,8 +211,7 @@ static gdouble bench_results[BENCHMARK_N_ENTRIES];
#include
#include
-#include
-#include
+#include
#include
#include
@@ -238,10 +233,10 @@ gchar *callback_bfsh()
"CPU Blowfish");
}
-gchar *callback_md5()
+gchar *callback_cryptohash()
{
- return benchmark_include_results_reverse(bench_results[BENCHMARK_MD5],
- "CPU MD5");
+ return benchmark_include_results_reverse(bench_results[BENCHMARK_CRYPTOHASH],
+ "CPU Cryptohash");
}
gchar *callback_fib()
@@ -250,12 +245,6 @@ gchar *callback_fib()
"CPU Fibonacci");
}
-gchar *callback_sha1()
-{
- return benchmark_include_results_reverse(bench_results[BENCHMARK_SHA1],
- "CPU SHA1");
-}
-
#define RUN_WITH_HIGH_PRIORITY(fn) \
do { \
int old_priority = getpriority(PRIO_PROCESS, 0); \
@@ -285,10 +274,10 @@ void scan_bfsh(gboolean reload)
SCAN_END();
}
-void scan_md5(gboolean reload)
+void scan_cryptohash(gboolean reload)
{
SCAN_START();
- RUN_WITH_HIGH_PRIORITY(benchmark_md5);
+ RUN_WITH_HIGH_PRIORITY(benchmark_cryptohash);
SCAN_END();
}
@@ -299,21 +288,13 @@ void scan_fib(gboolean reload)
SCAN_END();
}
-void scan_sha1(gboolean reload)
-{
- SCAN_START();
- RUN_WITH_HIGH_PRIORITY(benchmark_sha1);
- SCAN_END();
-}
-
const gchar *hi_note_func(gint entry)
{
switch (entry) {
case BENCHMARK_ZLIB:
return "Results in KiB/second. Higher is better.";
- case BENCHMARK_MD5:
- case BENCHMARK_SHA1:
+ case BENCHMARK_CRYPTOHASH:
return "Results in MiB/second. Higher is better.";
case BENCHMARK_RAYTRACE:
--
cgit v1.2.3