#include "bench.h" #include "bzlib.h" #include #include #include /* process 2 * 1/8 MB in 512 byte blocks */ #define BUF_SIZE 512 #define BUF_NR 128 void test_bzlib() { int gen2bz[2], bz2bz[2], bz2chk[2]; int result = 77; pipe(gen2bz); pipe(bz2bz); pipe(bz2chk); timer_start(CONTEXT_LOCAL); if ( !fork() ) { int c1, c2; char buffer[BUF_SIZE]; // close(gen2bz[1]); close(gen2bz[0]); close(bz2bz[1]); close(bz2bz[0]); close(bz2chk[1]); close(bz2chk[0]); // This is very random - so it's hard to compress ... for (c1=0; c1 0 ) { BZ2_bzwrite(b, buffer, rc); } BZ2_bzclose(b); _exit(0); } if ( !fork() ) { BZFILE *b = NULL; char buffer[BUF_SIZE]; int rc; close(gen2bz[1]); close(gen2bz[0]); close(bz2bz[1]); // close(bz2bz[0]); // close(bz2chk[1]); close(bz2chk[0]); b = BZ2_bzdopen(bz2bz[0], "r"); while ( (rc=BZ2_bzread(b, buffer, BUF_SIZE)) > 0 ) { write(bz2chk[1], buffer, rc); } BZ2_bzclose(b); _exit(0); } { int c1, rc; char buffer[BUF_SIZE]; close(gen2bz[1]); close(gen2bz[0]); close(bz2bz[1]); close(bz2bz[0]); close(bz2chk[1]); // close(bz2chk[0]); while ( (rc=read(bz2chk[0], buffer, BUF_SIZE)) > 0 ) { for (c1=0; c1