aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/benchmark.c22
-rw-r--r--modules/benchmark/bench_results.c12
-rw-r--r--modules/benchmark/benches.c25
-rw-r--r--modules/benchmark/blowfish.c30
-rw-r--r--modules/benchmark/drawing.c14
-rw-r--r--modules/benchmark/fft.c2
-rw-r--r--modules/benchmark/fftbench.c3
-rw-r--r--modules/benchmark/fib.c1
-rw-r--r--modules/benchmark/guibench.c465
-rw-r--r--modules/benchmark/md5.c29
-rw-r--r--modules/benchmark/sha1.c20
-rw-r--r--modules/computer/alsa.c2
-rw-r--r--modules/computer/filesystem.c4
-rw-r--r--modules/computer/modules.c2
-rw-r--r--modules/computer/uptime.c2
-rw-r--r--modules/devices/battery.c2
-rw-r--r--modules/devices/dmi.c2
-rw-r--r--modules/devices/spd-decode.c3
-rw-r--r--modules/devices/spd-vendors.c3
-rw-r--r--modules/devices/storage.c10
-rw-r--r--modules/network.c8
-rw-r--r--modules/network/net.c6
22 files changed, 250 insertions, 417 deletions
diff --git a/modules/benchmark.c b/modules/benchmark.c
index 511c984e..d4a39677 100644
--- a/modules/benchmark.c
+++ b/modules/benchmark.c
@@ -518,7 +518,7 @@ static gchar *benchmark_include_results_internal(bench_value this_machine_value,
ShellOrderType order_type)
{
bench_result *this_machine;
- GSList *result_list, *li;
+ GSList *result_list=NULL, *li;
gchar *results = g_strdup("");
gchar *output;
gchar *path;
@@ -603,6 +603,7 @@ do_benchmark_handler(GIOChannel *source, GIOCondition condition, gpointer data)
GIOStatus status;
gchar *result;
bench_value r = EMPTY_BENCH_VALUE;
+
status = g_io_channel_read_line(source, &result, NULL, NULL, NULL);
if (status != G_IO_STATUS_NORMAL) {
DEBUG("error while reading benchmark result");
@@ -657,8 +658,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)
bench_dialog = gtk_dialog_new_with_buttons ("Benchmarking...",
GTK_WINDOW(shell_get_main_shell()->transient_dialog),
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
- "Stop",
- GTK_BUTTONS_CLOSE,
+ _("Stop"), GTK_RESPONSE_ACCEPT,
NULL);
gtk_widget_set_sensitive(GTK_WIDGET(shell_get_main_shell()->transient_dialog), FALSE);
@@ -670,8 +670,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)
#else
box = gtk_hbox_new(FALSE, 1);
#endif
- label = gtk_label_new ("Please do not move your mouse\n"
- "or press any keys.");
+ label = gtk_label_new ("Please do not move your mouse\nor press any keys.");
gtk_widget_show (bench_image);
@@ -681,11 +680,6 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)
gtk_misc_set_alignment(GTK_MISC(bench_image), 0.0, 0.0);
#endif
- g_signal_connect_swapped (bench_dialog,
- "response",
- G_CALLBACK (gtk_widget_destroy),
- bench_dialog);
-
gtk_box_pack_start (GTK_BOX(box), bench_image, TRUE, TRUE, 10);
gtk_box_pack_start (GTK_BOX(box), label, TRUE, TRUE, 10);
gtk_container_add (GTK_CONTAINER(content_area), box);
@@ -720,16 +714,15 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)
switch (gtk_dialog_run(GTK_DIALOG(bench_dialog))) {
case GTK_RESPONSE_NONE:
DEBUG("benchmark finished");
+ bench_results[entry] = benchmark_dialog->r;
break;
case GTK_RESPONSE_ACCEPT:
DEBUG("cancelling benchmark");
-
gtk_widget_destroy(bench_dialog);
g_source_remove(watch_id);
kill(bench_pid, SIGINT);
}
- bench_results[entry] = benchmark_dialog->r;
g_io_channel_unref(channel);
shell_view_set_enabled(TRUE);
@@ -835,7 +828,8 @@ static gchar *get_benchmark_results(gsize *len)
ADD_JSON_VALUE(int, "MachineDataVersion",
this_machine->machine_data_version);
ADD_JSON_VALUE(string, "MachineType", this_machine->machine_type);
-
+ ADD_JSON_VALUE(string, "LinuxKernel", this_machine->linux_kernel);
+ ADD_JSON_VALUE(string, "LinuxOS", this_machine->linux_os);
ADD_JSON_VALUE(boolean, "Legacy", FALSE);
ADD_JSON_VALUE(string, "ExtraInfo", bench_results[i].extra);
ADD_JSON_VALUE(string, "UserNote", bench_results[i].user_note);
@@ -867,7 +861,7 @@ static gchar *run_benchmark(gchar *name)
{
int i;
- DEBUG("name = %s", name);
+ DEBUG("run_benchmark = %s", name);
for (i = 0; entries[i].name; i++) {
if (g_str_equal(entries[i].name, name)) {
diff --git a/modules/benchmark/bench_results.c b/modules/benchmark/bench_results.c
index e0557fc2..83c308bc 100644
--- a/modules/benchmark/bench_results.c
+++ b/modules/benchmark/bench_results.c
@@ -51,6 +51,8 @@ typedef struct {
char *ram_types;
int machine_data_version;
char *machine_type;
+ char *linux_kernel; /*kernelarch*/
+ char *linux_os; /*distroversion*/
} bench_machine;
typedef struct {
@@ -185,6 +187,8 @@ bench_machine *bench_machine_this()
m->memory_phys_MiB = memory_devices_get_system_memory_MiB();
m->ram_types = memory_devices_get_system_memory_types_str();
m->machine_type = module_call_method("computer::getMachineType");
+ m->linux_kernel = module_call_method("computer::getOSKernel");
+ m->linux_os = module_call_method("computer::getOS");
free(tmp);
cpu_procs_cores_threads_nodes(&m->processors, &m->cores, &m->threads, &m->nodes);
@@ -203,6 +207,8 @@ void bench_machine_free(bench_machine *s)
free(s->mid);
free(s->ram_types);
free(s->machine_type);
+ free(s->linux_kernel);
+ free(s->linux_os);
free(s);
}
}
@@ -426,7 +432,7 @@ bench_result *bench_result_benchmarkjson(const gchar *bench_name,
.result = json_get_double(machine, "BenchmarkResult"),
.elapsed_time = json_get_double(machine, "ElapsedTime"),
.threads_used = json_get_int(machine, "UsedThreads"),
- .revision = json_get_int(machine, "BenchmarkRevision"),
+ .revision = json_get_int(machine, "BenchmarkVersion"),//Revision
};
snprintf(b->bvalue.extra, sizeof(b->bvalue.extra), "%s",
@@ -556,6 +562,8 @@ static char *bench_result_more_info_complete(bench_result *b)
"[%s]\n"
/* board */ "%s=%s\n"
/* machine_type */ "%s=%s\n"
+ /* linux_kernel */ "%s=%s\n"
+ /* linux_os */ "%s=%s\n"
/* cpu */ "%s=%s\n"
/* cpudesc */ "%s=%s\n"
/* cpucfg */ "%s=%s\n"
@@ -584,6 +592,8 @@ static char *bench_result_more_info_complete(bench_result *b)
_("Machine"), _("Board"),
(b->machine->board != NULL) ? b->machine->board : _(unk),
_("Machine Type"), (b->machine->machine_type != NULL) ? b->machine->machine_type : _(unk),
+ _("Linux Kernel"), (b->machine->linux_kernel != NULL) ? b->machine->linux_kernel : _(unk),
+ _("Linux OS"), (b->machine->linux_os != NULL) ? b->machine->linux_os : _(unk),
_("CPU Name"),
b->machine->cpu_name, _("CPU Description"),
(b->machine->cpu_desc != NULL) ? b->machine->cpu_desc : _(unk),
diff --git a/modules/benchmark/benches.c b/modules/benchmark/benches.c
index 0b57ac1c..34ed5983 100644
--- a/modules/benchmark/benches.c
+++ b/modules/benchmark/benches.c
@@ -28,7 +28,7 @@ gchar *CN() { \
#define BENCH_SCAN_SIMPLE(SN, BF, BID) \
void SN(gboolean reload) { \
- SCAN_START(); \
+ static gboolean scanned = FALSE; if (reload || bench_results[BID].result<=0.0) scanned = FALSE;if (scanned) return; \
do_benchmark(BF, BID); \
SCAN_END(); \
}
@@ -56,17 +56,17 @@ BENCH_SIMPLE(BENCHMARK_MEMORY_DUAL, "SysBench Memory (Two threads)", benchmark_m
BENCH_SIMPLE(BENCHMARK_MEMORY_QUAD, "SysBench Memory (Quad threads)", benchmark_memory_quad, 1);
BENCH_SIMPLE(BENCHMARK_MEMORY_ALL, "SysBench Memory (Multi-thread)", benchmark_memory_all, 1);
-#if !GTK_CHECK_VERSION(3,0,0)
-BENCH_CALLBACK(callback_gui, "GPU Drawing", BENCHMARK_GUI, 1);
-void scan_gui(gboolean reload)
+BENCH_CALLBACK(callback_benchmark_gui, "GPU Drawing", BENCHMARK_GUI, 1);
+void scan_benchmark_gui(gboolean reload)
{
- SCAN_START();
+ static gboolean scanned = FALSE;
+ if (reload || bench_results[BENCHMARK_GUI].result<=0.0) scanned = FALSE;
+ if (scanned) return;
bench_value er = EMPTY_BENCH_VALUE;
if (params.run_benchmark) {
int argc = 0;
-
ui_init(&argc, NULL);
}
@@ -77,7 +77,6 @@ void scan_gui(gboolean reload)
}
SCAN_END();
}
-#endif
//Note: Same order as entries, used for json to server
static char *entries_english_name[] = {
@@ -238,18 +237,14 @@ static ModuleEntry entries[] = {
scan_benchmark_memory_all,
MODULE_FLAG_NONE,
},
-#if !GTK_CHECK_VERSION(3, 0, 0)
[BENCHMARK_GUI] =
{
N_("GPU Drawing"),
- "module.png",
- callback_gui,
- scan_gui,
- MODULE_FLAG_NO_REMOTE | MODULE_FLAG_HIDE,
+ "monitor.png",
+ callback_benchmark_gui,
+ scan_benchmark_gui,
+ MODULE_FLAG_NO_REMOTE,
},
-#else
- [BENCHMARK_GUI] = {"#"},
-#endif
{NULL}};
const gchar *hi_note_func(gint entry)
diff --git a/modules/benchmark/blowfish.c b/modules/benchmark/blowfish.c
index f8d2e14a..9cfacc81 100644
--- a/modules/benchmark/blowfish.c
+++ b/modules/benchmark/blowfish.c
@@ -1,23 +1,21 @@
/*
-blowfish.c: C implementation of the Blowfish algorithm.
-
-Copyright (C) 1997 by Paul Kocher
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-This library 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
-Lesser General Public License for more details.
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
+ * blowfish.c: C implementation of the Blowfish algorithm.
+ * Copyright (C) 1997 by Paul Kocher
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * This library 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
+ * Lesser General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+/*
COMMENTS ON USING THIS CODE:
Normal usage is as follows:
diff --git a/modules/benchmark/drawing.c b/modules/benchmark/drawing.c
index e92b9d62..1b1419be 100644
--- a/modules/benchmark/drawing.c
+++ b/modules/benchmark/drawing.c
@@ -19,15 +19,25 @@
#include "benchmark.h"
#include "guibench.h"
+#define BENCH_REVISION 3
+
void
benchmark_gui(void)
{
bench_value r = EMPTY_BENCH_VALUE;
+ double frametime[5];
+ int framecount[5];
shell_view_set_enabled(FALSE);
- shell_status_update("Running drawing benchmark...");
+ shell_status_update("Running GPU Drawing...");
- r.result = guibench(); //TODO: explain in code comments
+ r.result = guibench(frametime,framecount);
+ r.revision = BENCH_REVISION;
+#if GTK_CHECK_VERSION(3,0,0)
+ snprintf(r.extra, 255, "g:3 f:%0.4f/%0.4f/%0.4f/%0.4f/%0.4f c:%d/%d/%d/%d/%d",frametime[0],frametime[1],frametime[2],frametime[3],frametime[4],framecount[0],framecount[1],framecount[2],framecount[3],framecount[4]);
+#else
+ snprintf(r.extra, 255, "g:2 f:%0.4f/%0.4f/%0.4f/%0.4f/%0.4f c:%d/%d/%d/%d/%d",frametime[0],frametime[1],frametime[2],frametime[3],frametime[4],framecount[0],framecount[1],framecount[2],framecount[3],framecount[4]);
+#endif
bench_results[BENCHMARK_GUI] = r;
}
diff --git a/modules/benchmark/fft.c b/modules/benchmark/fft.c
index 503a7aaf..47acc369 100644
--- a/modules/benchmark/fft.c
+++ b/modules/benchmark/fft.c
@@ -21,7 +21,7 @@
#include "fftbench.h"
/* if anything changes in this block, increment revision */
-#define BENCH_REVISION 2
+#define BENCH_REVISION 3
#define CRUNCH_TIME 5
static gpointer fft_for(void *in_data, gint thread_number)
diff --git a/modules/benchmark/fftbench.c b/modules/benchmark/fftbench.c
index 9449cffd..a531e276 100644
--- a/modules/benchmark/fftbench.c
+++ b/modules/benchmark/fftbench.c
@@ -69,7 +69,7 @@ static void lup_decompose(FFTBench *fftbench)
double p, temp, **a;
int *perm = (int *) malloc(sizeof(double) * N);
-
+ free(fftbench->p);
fftbench->p = perm;
a = fftbench->a;
@@ -181,6 +181,7 @@ FFTBench *fft_bench_new(void)
}
fftbench->b = (double *) malloc(sizeof(double) * N);
+ fftbench->p = NULL;
for (i = 0; i < N; ++i)
fftbench->b[i] = random_double();
diff --git a/modules/benchmark/fib.c b/modules/benchmark/fib.c
index 2bec8bed..557c1b13 100644
--- a/modules/benchmark/fib.c
+++ b/modules/benchmark/fib.c
@@ -43,7 +43,6 @@ static gpointer fib_for(void *in_data, gint thread_number)
void
benchmark_fib(void)
{
- GTimer *timer = g_timer_new();
bench_value r = EMPTY_BENCH_VALUE;
shell_view_set_enabled(FALSE);
diff --git a/modules/benchmark/guibench.c b/modules/benchmark/guibench.c
index e0f8351e..1ca9f632 100644
--- a/modules/benchmark/guibench.c
+++ b/modules/benchmark/guibench.c
@@ -1,6 +1,6 @@
/*
- * HardInfo - Displays System Information
- * Copyright (C) 2003-2009 L. A. F. Pereira <l@tia.mat.br>
+ * hardinfo2 - System Information and Benchmark
+ * Copyright (C) 2024-2024 hwspeedy - hardinfo2 project
*
* 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
@@ -17,337 +17,154 @@
*/
#include <gtk/gtk.h>
+#include <cairo.h>
#include "iconcache.h"
#include "config.h"
-#define N_ITERATIONS 100000
-#define PHRASE "I \342\231\245 HardInfo"
-
-typedef double (*BenchCallback)(GtkWindow *window);
-
-static double test_lines(GtkWindow *window);
-static double test_shapes(GtkWindow *window);
-static double test_filled_shapes(GtkWindow *window);
-static double test_text(GtkWindow *window);
-static double test_icons(GtkWindow *window);
-
-/*
-Results on a AMD Athlon 3200+ (Barton), 1GB RAM,
-nVidia Geforce 6200 with nvidia Xorg driver,
-running Linux 2.6.28, Xorg 1.6.0, Ubuntu 9.04
-desktop, GNOME 2.26.1, composite enabled.
-
-Test Time Iter/Sec
-Line Drawing 3.9570 25271.7663
-Shape Drawing 22.2499 4494.4065
-Filled Shape Drawing 4.0377 24766.2806
-Text Drawing 59.1565 1690.4309
-Icon Blitting 51.720941 1933.4528
-
-Results are normalized according to these values.
-A guibench() result of 1000.0 is roughly equivalent
-to this same setup.
-*/
-
-static struct {
- BenchCallback callback;
- gchar *title;
- gdouble weight;
-} tests[] = {
- { test_lines, "Line Drawing", 25271.77 },
- { test_shapes, "Shape Drawing", 4494.49 },
- { test_filled_shapes, "Filled Shape Drawing", 24766.28 },
- { test_text, "Text Drawing", 1690.43 },
- { test_icons, "Icon Blitting", 1933.45 },
- { NULL, NULL }
-};
-
-static gchar *phrase = NULL;
-
-static gboolean keypress_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
-{
- const int magic[] = { 0x1b, 0x33, 0x3a, 0x35, 0x51 };
- const unsigned int states[] = { 0xff52, 0xff52, 0xff54, 0xff54,
- 0xff51, 0xff53, 0xff51, 0xff53,
- 0x62, 0x61 };
- static int state = 0;
-
- if (event->keyval == states[state]) {
- state++;
- } else {
- state = 0;
- }
-
- if (state == G_N_ELEMENTS(states)) {
- unsigned int i;
-
- for (i = 0; i < G_N_ELEMENTS(magic); i++) {
- phrase[i + 6] = magic[i] ^ (states[i] & (states[i] >> 8));
- }
+#define CRUNCH_TIME 3
+
+static int count=0;
+static int testnumber=0;
+static GTimer *timer,*frametimer;
+static gdouble score = 0.0f;
+static GdkPixbuf *pixbufs[3];
+static GRand *r;
+double *frametime;
+int *framecount;
+
+gboolean on_draw (GtkWidget *widget, GdkEventExpose *event, gpointer data) {
+#if GTK_CHECK_VERSION(3,0,0)
+ const int divfactor[5]={2231,2122,2113,2334,2332};
+#else //Note: OLD GTK does not do the same amount of work
+ const int divfactor[5]={12231,12122,12113,12334,12332};
+#endif
+ const int iterations[5]={100,300,100,300,100};
+ int i;
+ cairo_t * cr;
+ GdkWindow* window = gtk_widget_get_window(widget);
+
+
+#if GTK_CHECK_VERSION(3,22,0)
+ cairo_region_t * cairoRegion = cairo_region_create();
+ GdkDrawingContext * drawingContext;
- state = 0;
- }
-
- return FALSE;
+ drawingContext = gdk_window_begin_draw_frame (window,cairoRegion);
+ cr = gdk_drawing_context_get_cairo_context (drawingContext);
+#else
+ cr = gdk_cairo_create(window);
+#endif
+
+ g_timer_continue(frametimer);
+ for (i = iterations[testnumber]; i >= 0; i--) {
+ switch(testnumber) {
+ case 0 : //Line Drawing
+ cairo_move_to(cr, g_rand_int_range(r,0,1024), g_rand_int_range(r,0,800));
+ cairo_set_source_rgb(cr,g_rand_double_range(r,0,1),g_rand_double_range(r,0,1),g_rand_double_range(r,0,1));
+ cairo_line_to(cr, g_rand_int_range(r,0,1024), g_rand_int_range(r,0,800));
+ cairo_stroke(cr);
+ break;
+ case 1 : //Shape Drawing
+ cairo_rectangle(cr,g_rand_int_range(r,0,1024-200),g_rand_int_range(r,0,800-200),g_rand_int_range(r,0,400),g_rand_int_range(r,0,300));
+ cairo_set_source_rgb(cr,g_rand_double_range(r,0,1),g_rand_double_range(r,0,1),g_rand_double_range(r,0,1));
+ cairo_stroke(cr);
+ break;
+ case 2 : //Filled Shape Drawing
+ cairo_rectangle(cr,g_rand_int_range(r,0,1024-200),g_rand_int_range(r,0,800-200),g_rand_int_range(r,0,400),g_rand_int_range(r,0,300));
+ cairo_set_source_rgb(cr,g_rand_double_range(r,0,1),g_rand_double_range(r,0,1),g_rand_double_range(r,0,1));
+ cairo_fill(cr);
+ break;
+ case 3 : //Text Drawing
+ cairo_move_to(cr,g_rand_int_range(r,0,1024-100),g_rand_int_range(r,0,800));
+ cairo_set_font_size(cr,25);
+ cairo_set_source_rgb(cr,g_rand_double_range(r,0,1),g_rand_double_range(r,0,1),g_rand_double_range(r,0,1));
+ cairo_show_text(cr, "I \342\231\245 hardinfo2");
+ break;
+ //
+ case 4 : //Icon Blitting
+ gdk_cairo_set_source_pixbuf (cr, pixbufs[g_rand_int_range(r,0,3)],g_rand_int_range(r,0,1024-64), g_rand_int_range(r,0,800-64));
+ cairo_paint(cr);
+ break;
+ }
+ }
+ g_timer_stop(frametimer);
+#if GTK_CHECK_VERSION(3,22,0)
+ gdk_window_end_draw_frame(window,drawingContext);
+#endif
+ count++;
+ if(g_timer_elapsed(timer, NULL)<CRUNCH_TIME) {
+ gtk_widget_queue_draw_area(widget,0,0,1024,800);
+ } else {
+ score += ((double)iterations[testnumber]*count/g_timer_elapsed(frametimer,NULL)) / divfactor[testnumber];
+ frametime[testnumber]=g_timer_elapsed(frametimer,NULL);
+ framecount[testnumber]=count;
+ DEBUG("GPU Test %d => %d =>score:%f (frametime=%f)",testnumber,count,score,g_timer_elapsed(frametimer,NULL));
+ count=0;
+ testnumber++;
+ //Done
+ if(testnumber>=5){
+ gtk_main_quit();
+ } else {
+ g_timer_start(frametimer);
+ g_timer_stop(frametimer);
+ g_timer_start(timer);
+ gtk_widget_queue_draw_area(widget,0,0,1024,800);
+ }
+ }
+
+ // cleanup
+#if GTK_CHECK_VERSION(3,22,0)
+ cairo_region_destroy(cairoRegion);
+#endif
+
+ return FALSE;
}
-static double test_icons(GtkWindow *window)
-{
- GdkPixbuf *pixbufs[3];
- GdkGC *gc;
- GRand *rand;
- GTimer *timer;
- double time;
- GdkWindow *gdk_window = GTK_WIDGET(window)->window;
- int icons;
-
- gdk_window_clear(gdk_window);
-
- rand = g_rand_new();
- gc = gdk_gc_new(GDK_DRAWABLE(gdk_window));
- timer = g_timer_new();
-
- pixbufs[0] = icon_cache_get_pixbuf("hardinfo2.png");
- pixbufs[1] = icon_cache_get_pixbuf("syncmanager.png");
- pixbufs[2] = icon_cache_get_pixbuf("report-large.png");
-
- g_timer_start(timer);
- for (icons = N_ITERATIONS; icons >= 0; icons--) {
- int x, y;
- x = g_rand_int_range(rand, 0, 800);
- y = g_rand_int_range(rand, 0, 600);
-
- gdk_draw_pixbuf(GDK_DRAWABLE(gdk_window), gc,
- pixbufs[icons % G_N_ELEMENTS(pixbufs)],
- 0, 0, x, y, 48, 48,
- GDK_RGB_DITHER_NONE, 0, 0);
-
- while (gtk_events_pending()) {
- gtk_main_iteration();
- }
- }
- g_timer_stop(timer);
-
- time = g_timer_elapsed(timer, NULL);
-
- g_rand_free(rand);
- gdk_gc_destroy(gc);
- g_timer_destroy(timer);
-
- return time;
-}
-
-static double test_text(GtkWindow *window)
+double guibench(double *frameTime, int *frameCount)
{
- GRand *rand;
- GTimer *timer;
- GdkGC *gc;
- double time;
- PangoLayout *layout;
- PangoFontDescription *font;
- GdkWindow *gdk_window = GTK_WIDGET(window)->window;
- int strings;
-
- gdk_window_clear(gdk_window);
-
- rand = g_rand_new();
- gc = gdk_gc_new(GDK_DRAWABLE(gdk_window));
- timer = g_timer_new();
-
- font = pango_font_description_new();
- layout = pango_layout_new(gtk_widget_get_pango_context(GTK_WIDGET(window)));
- pango_layout_set_text(layout, phrase, -1);
-
- g_timer_start(timer);
- for (strings = N_ITERATIONS; strings >= 0; strings--) {
- int x, y, size;
-
- x = g_rand_int_range(rand, 0, 800);
- y = g_rand_int_range(rand, 0, 600);
- size = g_rand_int_range(rand, 1, 96) * PANGO_SCALE;
-
- pango_font_description_set_size(font, size);
- pango_layout_set_font_description(layout, font);
- gdk_draw_layout(GDK_DRAWABLE(gdk_window), gc, x, y, layout);
-
- gdk_rgb_gc_set_foreground(gc, strings << 8);
-
- while (gtk_events_pending()) {
- gtk_main_iteration();
- }
-
- }
- g_timer_stop(timer);
-
- time = g_timer_elapsed(timer, NULL);
-
- g_rand_free(rand);
- gdk_gc_destroy(gc);
- g_timer_destroy(timer);
- g_object_unref(layout);
- pango_font_description_free(font);
-
- return time;
-}
-
-static double test_filled_shapes(GtkWindow *window)
-{
- GRand *rand;
- GTimer *timer;
- GdkGC *gc;
- double time;
- GdkWindow *gdk_window = GTK_WIDGET(window)->window;
- int lines;
-
- gdk_window_clear(gdk_window);
-
- rand = g_rand_new();
- gc = gdk_gc_new(GDK_DRAWABLE(gdk_window));
- timer = g_timer_new();
-
- g_timer_start(timer);
- for (lines = N_ITERATIONS; lines >= 0; lines--) {
- int x1, y1;
-
- x1 = g_rand_int_range(rand, 0, 800);
- y1 = g_rand_int_range(rand, 0, 600);
-
- gdk_rgb_gc_set_foreground(gc, lines << 8);
-
- gdk_draw_rectangle(GDK_DRAWABLE(gdk_window), gc, TRUE,
- x1, y1,
- g_rand_int_range(rand, 0, 400),
- g_rand_int_range(rand, 0, 300));
-
- while (gtk_events_pending()) {
- gtk_main_iteration();
- }
- }
- g_timer_stop(timer);
-
- time = g_timer_elapsed(timer, NULL);
-
- g_rand_free(rand);
- gdk_gc_destroy(gc);
- g_timer_destroy(timer);
-
- return time;
-}
-
-static double test_shapes(GtkWindow *window)
-{
- GRand *rand;
- GTimer *timer;
- GdkGC *gc;
- double time;
- GdkWindow *gdk_window = GTK_WIDGET(window)->window;
- int lines;
-
- gdk_window_clear(gdk_window);
-
- rand = g_rand_new();
- gc = gdk_gc_new(GDK_DRAWABLE(gdk_window));
- timer = g_timer_new();
-
- g_timer_start(timer);
- for (lines = N_ITERATIONS; lines >= 0; lines--) {
- int x1, y1;
-
- x1 = g_rand_int_range(rand, 0, 800);
- y1 = g_rand_int_range(rand, 0, 600);
-
- gdk_rgb_gc_set_foreground(gc, lines << 8);
-
- gdk_draw_rectangle(GDK_DRAWABLE(gdk_window), gc, FALSE,
- x1, y1,
- g_rand_int_range(rand, 0, 400),
- g_rand_int_range(rand, 0, 300));
- while (gtk_events_pending()) {
- gtk_main_iteration();
- }
- }
- g_timer_stop(timer);
-
- time = g_timer_elapsed(timer, NULL);
-
- g_rand_free(rand);
- gdk_gc_destroy(gc);
- g_timer_destroy(timer);
-
- return time;
-}
-
-static double test_lines(GtkWindow *window)
-{
- GRand *rand;
- GTimer *timer;
- GdkGC *gc;
- double time;
- GdkWindow *gdk_window = GTK_WIDGET(window)->window;
- int lines;
-
- gdk_window_clear(gdk_window);
-
- rand = g_rand_new();
- gc = gdk_gc_new(GDK_DRAWABLE(gdk_window));
- timer = g_timer_new();
-
- g_timer_start(timer);
- for (lines = N_ITERATIONS; lines >= 0; lines--) {
- int x1, y1, x2, y2;
-
- x1 = g_rand_int_range(rand, 0, 800);
- y1 = g_rand_int_range(rand, 0, 600);
- x2 = g_rand_int_range(rand, 0, 800);
- y2 = g_rand_int_range(rand, 0, 600);
-
- gdk_draw_line(GDK_DRAWABLE(gdk_window), gc, x1, y1, x2, y2);
- gdk_rgb_gc_set_foreground(gc, lines << 8);
-
- while (gtk_events_pending()) {
- gtk_main_iteration();
- }
- }
- g_timer_stop(timer);
-
- time = g_timer_elapsed(timer, NULL);
-
- g_rand_free(rand);
- gdk_gc_destroy(gc);
- g_timer_destroy(timer);
-
- return time;
-}
-
-double guibench(void)
-{
- GtkWidget *window;
- gdouble score = 0.0f;
- gint i;
-
- phrase = g_strdup(PHRASE);
-
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_size_request(window, 800, 600);
- gtk_window_set_title(GTK_WINDOW(window), "guibench");
-
- gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ON_PARENT);
- gtk_widget_show(window);
-
- g_signal_connect(window, "key-press-event", G_CALLBACK(keypress_event), NULL);
+ GtkWindow * window;
+ cairo_t *cr;
- for (i = 0; tests[i].title; i++) {
- double time;
+ frametime=frameTime;
+ framecount=frameCount;
- gtk_window_set_title(GTK_WINDOW(window), tests[i].title);
- time = tests[i].callback(GTK_WINDOW(window));
- score += (N_ITERATIONS / time) / tests[i].weight;
- }
-
- gtk_widget_destroy(window);
- g_free(phrase);
-
- return (score / i) * 1000.0f;
+ DEBUG("GUIBENCH");
+ pixbufs[0] = gdk_pixbuf_scale_simple(icon_cache_get_pixbuf("hardinfo2.png"),64,64,GDK_INTERP_BILINEAR);
+ pixbufs[1] = gdk_pixbuf_scale_simple(icon_cache_get_pixbuf("syncmanager.png"),64,64,GDK_INTERP_BILINEAR);
+ pixbufs[2] = gdk_pixbuf_scale_simple(icon_cache_get_pixbuf("report-large.png"),64,64,GDK_INTERP_BILINEAR);
+
+ r = g_rand_new();
+
+ // window setup
+ window = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_default_size (window, 1024, 800);
+ gtk_window_set_position (window, GTK_WIN_POS_CENTER);
+ gtk_window_set_title (window, "GPU Benchmarking...");
+ g_signal_connect(window, "destroy", gtk_main_quit, NULL);
+
+ // create the are we can draw in
+ GtkDrawingArea* drawingArea;
+ drawingArea = (GtkDrawingArea*) gtk_drawing_area_new();
+ gtk_container_add(GTK_CONTAINER(window), (GtkWidget*)drawingArea);
+#if GTK_CHECK_VERSION(3,0,0)
+ g_signal_connect((GtkWidget*)drawingArea, "draw", G_CALLBACK(on_draw), NULL);
+#else
+ g_signal_connect((GtkWidget*)drawingArea, "expose-event", G_CALLBACK(on_draw), NULL);
+#endif
+ frametimer = g_timer_new();
+ g_timer_stop(frametimer);
+ timer = g_timer_new();
+ gtk_widget_show_all ((GtkWidget*)window);
+
+ gtk_main();
+
+ g_timer_destroy(timer);
+ g_timer_destroy(frametimer);
+ g_rand_free(r);
+ g_object_unref(pixbufs[0]);
+ g_object_unref(pixbufs[1]);
+ g_object_unref(pixbufs[2]);
+
+ return score;
}
diff --git a/modules/benchmark/md5.c b/modules/benchmark/md5.c
index f4032ddd..8cb22d93 100644
--- a/modules/benchmark/md5.c
+++ b/modules/benchmark/md5.c
@@ -2,27 +2,22 @@
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
* written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
+ * Copyright by: hardinfo2 project
+
+ * 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 or later.
*
- * Equivalent code is available from RSA Data Security, Inc.
- * This code has been tested against that, and is equivalent,
- * except that you don't need to include two pages of legalese
- * with every copy.
+ * 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.
*
- * To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to MD5Init, call MD5Update as
- * needed on buffers full of bytes, and then call MD5Final, which
- * will fill a supplied 16-byte array with the digest.
+ * 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
*/
-/* This code was modified in 1997 by Jim Kingdon of Cyclic Software to
- not require an integer type which is exactly 32 bits. This work
- draws on the changes for the same purpose by Tatu Ylonen
- <ylo@cs.hut.fi> as part of SSH, but since I didn't actually use
- that code, there is no copyright issue. I hereby disclaim
- copyright in any changes I have made; this code remains in the
- public domain. */
-
#include <string.h> /* for memcpy() and memset() */
/* Add prototype support. */
diff --git a/modules/benchmark/sha1.c b/modules/benchmark/sha1.c
index 3b213218..8cbf0f6a 100644
--- a/modules/benchmark/sha1.c
+++ b/modules/benchmark/sha1.c
@@ -1,8 +1,22 @@
/*
-SHA-1 in C
-By Steve Reid <steve@edmweb.com>
-100% Public Domain
+ * SHA-1 in C
+ * Written by Steve Reid <steve@edmweb.com>
+ * Copyright by: hardinfo2 project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License v2.0 or later.
+ *
+ * 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
+ */
+/*
Test Vectors (from FIPS PUB 180-1)
"abc"
A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
diff --git a/modules/computer/alsa.c b/modules/computer/alsa.c
index f74d2752..de20a0ad 100644
--- a/modules/computer/alsa.c
+++ b/modules/computer/alsa.c
@@ -63,7 +63,7 @@ computer_get_alsainfo(void)
ai->cards = g_slist_append(ai->cards, ac);
g_strfreev(tmp);
- (void)fgets(buffer, 128, cards); /* skip next line */
+ char *c=fgets(buffer, 128, cards); /* skip next line */
}
fclose(cards);
diff --git a/modules/computer/filesystem.c b/modules/computer/filesystem.c
index e9c84811..2aa31f67 100644
--- a/modules/computer/filesystem.c
+++ b/modules/computer/filesystem.c
@@ -17,7 +17,9 @@
*
* Some code from xfce4-mount-plugin, version 0.4.3
* Copyright (C) 2005 Jean-Baptiste jb_dul@yahoo.com
- * Distributed under the terms of GNU GPL 2.
+ * Distributed under the terms of GNU GPL 2+ -
+ * https://gitlab.xfce.org/panel-plugins/xfce4-mount-plugin/-/blob/master/panel-plugin/mount-plugin.c
+.*
*/
#include <string.h>
diff --git a/modules/computer/modules.c b/modules/computer/modules.c
index cec2d42e..e3423ed8 100644
--- a/modules/computer/modules.c
+++ b/modules/computer/modules.c
@@ -265,7 +265,7 @@ void scan_modules_do(void) {
return;
}
- (void)fgets(buffer, 1024, lsmod); /* Discards the first line */
+ char *c=fgets(buffer, 1024, lsmod); /* Discards the first line */
//Sort modules
while (fgets(buffer, 1024, lsmod)) {
diff --git a/modules/computer/uptime.c b/modules/computer/uptime.c
index 8aef1530..f213442f 100644
--- a/modules/computer/uptime.c
+++ b/modules/computer/uptime.c
@@ -26,7 +26,7 @@ computer_get_uptime(void)
gulong minutes;
if ((procuptime = fopen("/proc/uptime", "r")) != NULL) {
- (void)fscanf(procuptime, "%lu", &minutes);
+ int c=fscanf(procuptime, "%lu", &minutes);
ui->minutes = minutes / 60;
fclose(procuptime);
} else {
diff --git a/modules/devices/battery.c b/modules/devices/battery.c
index e356c14a..784a6cc5 100644
--- a/modules/devices/battery.c
+++ b/modules/devices/battery.c
@@ -312,7 +312,7 @@ __scan_battery_apm(void)
if ((procapm = fopen("/proc/apm", "r"))) {
int old_percentage = percentage;
- (void)fscanf(procapm, "%s %s %s 0x%x %s %s %d%%",
+ int c=fscanf(procapm, "%s %s %s 0x%x %s %s %d%%",
apm_drv_ver, apm_bios_ver, trash,
&ac_bat, trash, trash, &percentage);
fclose(procapm);
diff --git a/modules/devices/dmi.c b/modules/devices/dmi.c
index 34374fbe..af02e6d4 100644
--- a/modules/devices/dmi.c
+++ b/modules/devices/dmi.c
@@ -73,7 +73,7 @@ gboolean dmi_get_info(void)
DMIInfo *info;
gboolean dmi_succeeded = FALSE;
guint i;
- gchar *value;
+ gchar *value=NULL;
const gchar *vendor;
if (dmi_info) {
diff --git a/modules/devices/spd-decode.c b/modules/devices/spd-decode.c
index cf4c89d7..7cfc688c 100644
--- a/modules/devices/spd-decode.c
+++ b/modules/devices/spd-decode.c
@@ -20,8 +20,7 @@
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ctype.h>
diff --git a/modules/devices/spd-vendors.c b/modules/devices/spd-vendors.c
index 80b2a6a4..7a646758 100644
--- a/modules/devices/spd-vendors.c
+++ b/modules/devices/spd-vendors.c
@@ -20,8 +20,7 @@
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* from decode-dimms, in the i2c-tools package:
diff --git a/modules/devices/storage.c b/modules/devices/storage.c
index bbf9b195..c0bee0d2 100644
--- a/modules/devices/storage.c
+++ b/modules/devices/storage.c
@@ -632,7 +632,7 @@ void __scan_ide_devices(void)
if (!proc_ide)
continue;
- (void) fgets(buf, 128, proc_ide);
+ char *cc=fgets(buf, 128, proc_ide);
fclose(proc_ide);
buf[strlen(buf) - 1] = 0;
@@ -648,7 +648,7 @@ void __scan_ide_devices(void)
continue;
}
- (void) fgets(buf, 128, proc_ide);
+ char *c=fgets(buf, 128, proc_ide);
fclose(proc_ide);
buf[strlen(buf) - 1] = 0;
@@ -717,7 +717,7 @@ void __scan_ide_devices(void)
if (g_file_test(device, G_FILE_TEST_EXISTS)) {
proc_ide = fopen(device, "r");
if (proc_ide) {
- (void) fscanf(proc_ide, "%d", &cache);
+ int c=fscanf(proc_ide, "%d", &cache);
fclose(proc_ide);
} else {
cache = 0;
@@ -731,7 +731,7 @@ void __scan_ide_devices(void)
proc_ide = fopen(device, "r");
if (proc_ide) {
- (void) fgets(buf, 64, proc_ide);
+ char *c=fgets(buf, 64, proc_ide);
for (tmp = buf; *tmp; tmp++) {
if (*tmp >= '0' && *tmp <= '9')
break;
@@ -739,7 +739,7 @@ void __scan_ide_devices(void)
pgeometry = g_strdup(g_strstrip(tmp));
- (void) fgets(buf, 64, proc_ide);
+ char *cc=fgets(buf, 64, proc_ide);
for (tmp = buf; *tmp; tmp++) {
if (*tmp >= '0' && *tmp <= '9')
break;
diff --git a/modules/network.c b/modules/network.c
index 4b65e0aa..e89e1b6b 100644
--- a/modules/network.c
+++ b/modules/network.c
@@ -151,7 +151,7 @@ void scan_dns(gboolean reload)
ip = g_strstrip(buffer + sizeof("nameserver"));
sa.sin_family = AF_INET;
- sa.sin_addr.s_addr = inet_addr(ip);
+ inet_pton(AF_INET,ip,&sa.sin_addr.s_addr);
if (getnameinfo((struct sockaddr *)&sa, sizeof(sa), hbuf, sizeof(hbuf), NULL, 0, NI_NAMEREQD)) {
__nameservers = h_strdup_cprintf("%s=\n",
@@ -196,8 +196,8 @@ void scan_route(gboolean reload)
if ((route = popen(command_line, "r"))) {
/* eat first two lines */
- (void)fgets(buffer, 256, route);
- (void)fgets(buffer, 256, route);
+ char *c=fgets(buffer, 256, route);
+ char *cc=fgets(buffer, 256, route);
while (fgets(buffer, 256, route)) {
buffer[15] = '\0';
@@ -236,7 +236,7 @@ void scan_arp(gboolean reload)
if ((arp = fopen("/proc/net/arp", "r"))) {
/* eat first line */
- (void)fgets(buffer, 256, arp);
+ char *c=fgets(buffer, 256, arp);
while (fgets(buffer, 256, arp)) {
buffer[15] = '\0';
diff --git a/modules/network/net.c b/modules/network/net.c
index 9a5cb5f1..f584362b 100644
--- a/modules/network/net.c
+++ b/modules/network/net.c
@@ -200,9 +200,9 @@ void get_net_info(char *if_name, NetInfo * netinfo)
if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) {
netinfo->ip[0] = 0;
} else {
- snprintf(netinfo->ip, sizeof(netinfo->ip), "%s",
- inet_ntoa(((struct sockaddr_in *) &ifr.ifr_addr)->
- sin_addr));
+ char ipstr[INET_ADDRSTRLEN];
+ inet_ntop(AF_INET, &((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr, ipstr, INET_ADDRSTRLEN);
+ snprintf(netinfo->ip, sizeof(netinfo->ip), "%s",ipstr);
}
/* Mask Address */