diff options
Diffstat (limited to 'modules/benchmark')
| -rw-r--r-- | modules/benchmark/bench_results.c | 12 | ||||
| -rw-r--r-- | modules/benchmark/benches.c | 25 | ||||
| -rw-r--r-- | modules/benchmark/blowfish.c | 30 | ||||
| -rw-r--r-- | modules/benchmark/drawing.c | 14 | ||||
| -rw-r--r-- | modules/benchmark/fft.c | 2 | ||||
| -rw-r--r-- | modules/benchmark/fftbench.c | 3 | ||||
| -rw-r--r-- | modules/benchmark/fib.c | 1 | ||||
| -rw-r--r-- | modules/benchmark/guibench.c | 465 | ||||
| -rw-r--r-- | modules/benchmark/md5.c | 29 | ||||
| -rw-r--r-- | modules/benchmark/sha1.c | 20 | 
10 files changed, 220 insertions, 381 deletions
| 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 | 
