On Thu, 15 Mar 2007, Linus Torvalds wrote:Didn't do proper cache warmup and test time was fairly short. Now I'm not able to notice substantial differences. Hacked up test case below ... - Davide /* example.c -- usage example of the zlib compression library * Copyright (C) 1995-2004 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #include <sys/time.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #include "zlib.h" #define CHECK_ERR(err, msg) do { \ if (err != Z_OK) { \ fprintf(stderr, "%s error: %d\n", msg, err); \ exit(1); \ } \ } while (0) unsigned long long getustime(void) { struct timeval tm; gettimeofday(&tm, NULL); return tm.tv_sec * 1000000ULL + tm.tv_usec; } /* =========================================================================== * Test deflate() with large buffers and dynamic change of compression level */ void do_defl(Byte *compr, uLong *comprLen, Byte *uncompr, uLong uncomprLen) { z_stream c_stream; /* compression stream */ int err; c_stream.zalloc = (alloc_func)0; c_stream.zfree = (free_func)0; c_stream.opaque = (voidpf)0; err = deflateInit(&c_stream, Z_BEST_SPEED); CHECK_ERR(err, "deflateInit"); c_stream.next_out = compr; c_stream.avail_out = (uInt) *comprLen; /* At this point, uncompr is still mostly zeroes, so it should compress * very well: */ c_stream.next_in = uncompr; c_stream.avail_in = (uInt) uncomprLen; err = deflate(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { fprintf(stderr, "whoops, got %d instead of Z_STREAM_END\n", err); exit(1); } err = deflateEnd(&c_stream); CHECK_ERR(err, "deflateEnd"); *comprLen = c_stream.next_out - compr; } /* =========================================================================== * Test inflate() with large buffers */ void do_infl(Byte *compr, uLong comprLen, Byte *uncompr, uLong *uncomprLen) { int err; z_stream d_stream; /* decompression stream */ d_stream.zalloc = (alloc_func)0; d_stream.zfree = (free_func)0; d_stream.opaque = (voidpf)0; d_stream.next_in = compr; d_stream.avail_in = (uInt)comprLen; err = inflateInit(&d_stream); CHECK_ERR(err, "inflateInit"); d_stream.next_out = uncompr; /* discard the output */ d_stream.avail_out = (uInt) *uncomprLen; err = inflate(&d_stream, Z_FULL_FLUSH); if (err != Z_STREAM_END) { fprintf(stderr, "deflate should report Z_STREAM_END\n"); exit(1); } err = inflateEnd(&d_stream); CHECK_ERR(err, "inflateEnd"); *uncomprLen = d_stream.next_out - uncompr; } int main(int ac, char **av) { uLong i, n, clen, ulen, size = 8 * 1024 * 1024, range = 256; Byte *ubuf, *cbuf, *tbuf; unsigned long long ts, te; srand(1); ulen = size; clen = 2 * ulen; ubuf = malloc(ulen); tbuf = malloc(ulen); cbuf = malloc(clen); for (i = 0; i < ulen; i++) ubuf[i] = (Byte) (rand() % range); /* Warming up ... */ do_defl(cbuf, &clen, ubuf, ulen); do_infl(cbuf, clen, tbuf, &ulen); if (ulen != size) { fprintf(stderr, "size mismatch %lu instead of %lu\n", (unsigned long) ulen, (unsigned long) size); return 1; } if (memcmp(tbuf, ubuf, size)) { fprintf(stderr, "whoops! we did not get back the same data\n"); return 2; } /* Test ... */ ts = getustime(); n = 0; do { for (i = 0; i < 16; i++) { ulen = size; do_infl(cbuf, clen, ubuf, &ulen); } n += i; te = getustime(); } while (te - ts < 2 * 1000000); fprintf(stdout, "us time / cycle = %llu\n", (te - ts) / n); return 0; } - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| James Bottomley | Re: Announce: Linux-next (Or Andrew's dream :-)) |
| Trent Piepho | Re: [PATCH] fakephp: Allocate PCI resources before adding the device |
| Antonio Almeida | HTB accuracy for high speed |
| David Miller | [GIT]: Networking |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
git: | |
