diff options
| author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2008-10-30 19:46:50 -0300 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2008-10-30 19:46:50 -0300 | 
| commit | 69268767f3055cb6e1548459185c2617ef7977f6 (patch) | |
| tree | 347ec46bbd08c804c84d0fd7523916134cf2af00 /hardinfo2/arch | |
| parent | 8914b84d5db87443b311a9646c9c93ea2b4f2c27 (diff) | |
| parent | 1d2c77e7e1b4c3fcbc6a36dd89fe3287c324e032 (diff) | |
Merge branch 'master' of git@github.com:lpereira/hardinfo
Diffstat (limited to 'hardinfo2/arch')
| -rw-r--r-- | hardinfo2/arch/common/cryptohash.h (renamed from hardinfo2/arch/common/md5.h) | 65 | ||||
| -rw-r--r-- | hardinfo2/arch/common/sha1.h | 62 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/alpha/processor.h | 3 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/armv4l/processor.h | 4 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/common/filesystem.h | 4 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/common/net.h | 13 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/ia64/processor.h | 4 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/s390/processor.h | 4 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/sparc/processor.h | 3 | 
9 files changed, 61 insertions, 101 deletions
| diff --git a/hardinfo2/arch/common/md5.h b/hardinfo2/arch/common/cryptohash.h index d839778a..9897bb6b 100644 --- a/hardinfo2/arch/common/md5.h +++ b/hardinfo2/arch/common/cryptohash.h @@ -17,21 +17,48 @@   */  #include <md5.h> +#include <sha1.h> -static void -benchmark_md5(void) +static void inline md5_step(char *data, glong srclen)  {      struct MD5Context ctx;      guchar checksum[16]; -    int i; -    GTimer *timer = g_timer_new(); -    gdouble elapsed = 0; -    gchar src[65536], *tmpsrc; -    glong srclen = 65536; +     +    MD5Init(&ctx); +    MD5Update(&ctx, (guchar *)data, srclen); +    MD5Final(checksum, &ctx); +} -    tmpsrc = src; +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); +} -    gchar *bdata_path; +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)) { @@ -40,24 +67,12 @@ benchmark_md5(void)      }           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_update("Running CryptoHash benchmark..."); -        shell_status_set_percentage(i/50); -    } +    elapsed = benchmark_parallel_for(0, 5000, cryptohash_for, tmpsrc); -    g_timer_destroy(timer);      g_free(bdata_path); +    g_free(tmpsrc); -    bench_results[BENCHMARK_MD5] = 312.0 / elapsed; +    bench_results[BENCHMARK_CRYPTOHASH] = 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 <leandro@hardinfo.org> - * - *    This program is free software; you can redistribute it and/or modify - *    it under the terms of the GNU General Public License as published by - *    the Free Software Foundation, version 2. - * - *    This program is distributed in the hope that it will be useful, - *    but WITHOUT ANY WARRANTY; without even the implied warranty of - *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - *    GNU General Public License for more details. - * - *    You should have received a copy of the GNU General Public License - *    along with this program; if not, write to the Free Software - *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA - */ -#include <sha1.h> - -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/arch/linux/alpha/processor.h b/hardinfo2/arch/linux/alpha/processor.h index e6013103..1e5b014c 100644 --- a/hardinfo2/arch/linux/alpha/processor.h +++ b/hardinfo2/arch/linux/alpha/processor.h @@ -18,7 +18,7 @@  struct _Processor {      gchar *model_name; -    gfloat bogomips; +    gfloat bogomips, cpu_mhz;      gchar *strmodel;  }; @@ -52,6 +52,7 @@ __scan_processors(void)      gchar *tmp = g_strconcat("Alpha ", processor->model_name, NULL);      g_free(processor->model_name);      processor->model_name = tmp; +    processor->cpu_mhz = 0.0f;      fclose(cpuinfo); diff --git a/hardinfo2/arch/linux/armv4l/processor.h b/hardinfo2/arch/linux/armv4l/processor.h index b64fd5eb..82b6be04 100644 --- a/hardinfo2/arch/linux/armv4l/processor.h +++ b/hardinfo2/arch/linux/armv4l/processor.h @@ -19,7 +19,7 @@  struct _Processor {      gchar *model_name;      gchar *flags; -    gfloat bogomips; +    gfloat bogomips, cpu_mhz;      gchar *has_fpu;  }; @@ -53,6 +53,8 @@ __scan_processors(void)  	g_strfreev(tmp);      } +    processor->cpu_mhz = 0.0f; +      fclose(cpuinfo);      return g_slist_append(NULL, processor); diff --git a/hardinfo2/arch/linux/common/filesystem.h b/hardinfo2/arch/linux/common/filesystem.h index 3581ccbb..b3008387 100644 --- a/hardinfo2/arch/linux/common/filesystem.h +++ b/hardinfo2/arch/linux/common/filesystem.h @@ -81,9 +81,9 @@ scan_filesystems(void)  					  stravail);  		g_hash_table_insert(moreinfo, g_strdup_printf("FS%d", ++count), strhash); -		fs_list = h_strdup_cprintf("$FS%d$%s=%s total, %s free\n", +		fs_list = h_strdup_cprintf("$FS%d$%s=%s|%s\n",  					  fs_list, -					  count, tmp[0], strsize, stravail); +					  count, tmp[0], stravail, strsize);  		g_free(strsize);  		g_free(stravail); diff --git a/hardinfo2/arch/linux/common/net.h b/hardinfo2/arch/linux/common/net.h index de978ee1..8c083a9e 100644 --- a/hardinfo2/arch/linux/common/net.h +++ b/hardinfo2/arch/linux/common/net.h @@ -314,7 +314,7 @@ static void scan_net_interfaces_24(void)  	    gint trash;  	    gchar ifacename[16];  	    gchar *buf = buffer; -	    gchar *iface_type, *iface_icon, *ip; +	    gchar *iface_type, *iface_icon;  	    gint i;  	    buf = g_strstrip(buf); @@ -340,16 +340,13 @@ static void scan_net_interfaces_24(void)  	    devid = g_strdup_printf("NET%s", ifacename); -	    ip = g_strdup_printf(" (%s)", ni.ip);  	    network_interfaces =  		h_strdup_cprintf -		("$%s$%s=Sent %.2lfMiB, received %.2lfMiB%s\n", -		 network_interfaces, devid, ifacename, trans_mb, recv_mb, -		 ni.ip[0] ? ip : ""); -	    g_free(ip); - +		("$%s$%s=%s|Sent %.2lfMiB, received %.2lfMiB\n", +		 network_interfaces, devid, ifacename, ni.ip[0] ? ni.ip : "", +		 trans_mb, recv_mb);  	    net_get_iface_type(ifacename, &iface_type, &iface_icon, &ni); -	     +  	    network_icons = h_strdup_cprintf("Icon$%s$%s=%s.png\n",  					     network_icons, devid,  					     ifacename, iface_icon); diff --git a/hardinfo2/arch/linux/ia64/processor.h b/hardinfo2/arch/linux/ia64/processor.h index d5e01776..d3d41519 100644 --- a/hardinfo2/arch/linux/ia64/processor.h +++ b/hardinfo2/arch/linux/ia64/processor.h @@ -19,7 +19,7 @@  struct _Processor {      gchar *model_name;      gchar *vendor_id; -    gfloat bogomips; +    gfloat bogomips, cpu_mhz;      gchar *strmodel;  }; @@ -50,6 +50,8 @@ __scan_processors(void)  	}  	g_strfreev(tmp);      } + +    processor->cpu_mhz = 0.0f;      fclose(cpuinfo); diff --git a/hardinfo2/arch/linux/s390/processor.h b/hardinfo2/arch/linux/s390/processor.h index 1550d239..25dab8ca 100644 --- a/hardinfo2/arch/linux/s390/processor.h +++ b/hardinfo2/arch/linux/s390/processor.h @@ -19,7 +19,7 @@  struct _Processor {      gchar *vendor_id, *model_name;      gint cache_size; -    gfloat bogomips; +    gfloat bogomips, cpu_mhz;  };  static GSList * @@ -48,6 +48,8 @@ __scan_processors(void)  	}  	g_strfreev(tmp);      } + +    processor->cpu_mhz = 0.0f;      processor->model_name = g_strconcat("S390 ", processor->vendor_id, NULL);      g_free(processor->vendor_id); diff --git a/hardinfo2/arch/linux/sparc/processor.h b/hardinfo2/arch/linux/sparc/processor.h index 3bbea922..0272c963 100644 --- a/hardinfo2/arch/linux/sparc/processor.h +++ b/hardinfo2/arch/linux/sparc/processor.h @@ -19,6 +19,7 @@  struct _Processor {      gchar *model_name;      gchar *has_fpu; +    gfloat cpu_mhz;  };  static GSList * @@ -48,6 +49,8 @@ __scan_processors(void)      fclose(cpuinfo); +    processor->cpu_mhz = 0.0f; +      return g_slist_append(NULL, processor);  } | 
