2
* HardInfo - Displays System Information
3
* Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, version 2.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
static gulong (*compressBound) (glong srclen) = NULL;
24
static gint (*compress) (gchar *dst, glong *dstlen,
25
const gchar *src, glong srclen) = NULL;
27
if (!(compress && compressBound)) {
28
libz = g_module_open("libz", G_MODULE_BIND_LAZY);
30
libz = g_module_open("/usr/lib/libz.so.1", G_MODULE_BIND_LAZY);
32
g_warning("Cannot load ZLib: %s", g_module_error());
37
if (!g_module_symbol(libz, "compress", (gpointer) & compress)
38
|| !g_module_symbol(libz, "compressBound", (gpointer) & compressBound)) {
45
shell_view_set_enabled(FALSE);
48
GTimer *timer = g_timer_new();
50
gchar src[65536], *tmpsrc;
54
bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL);
55
if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) {
60
shell_status_update("Compressing 64MB with default options...");
62
for (i = 0; i <= 1000; i++) {
66
glong dstlen = compressBound(srclen);
68
dst = g_new0(gchar, dstlen);
69
compress(dst, &dstlen, src, srclen);
72
elapsed += g_timer_elapsed(timer, NULL);
75
shell_status_set_percentage(i/10);
78
g_timer_destroy(timer);
81
bench_results[BENCHMARK_ZLIB] = 65536.0 / elapsed;