diff --git a/igzip/igzip_perf.c b/igzip/igzip_perf.c index d21cf95..7d5a6f4 100644 --- a/igzip/igzip_perf.c +++ b/igzip/igzip_perf.c @@ -39,7 +39,7 @@ #define BUF_SIZE 1024 -#define OPTARGS "hl:f:z:i:d:stub:y:w:" +#define OPTARGS "hl:f:z:i:d:stub:y:w:o:" #define COMPRESSION_QUEUE_LIMIT 32 #define UNSET -1 @@ -154,6 +154,7 @@ int usage(void) " -s performance test isa-l stateful inflate\n" " -t performance test isa-l stateless inflate\n" " -u performance test zlib inflate\n" + " -o output file to store compressed data (last one if multiple)\n" " -b input buffer size, applies to stateful options (-f,-z,-s)\n" " -y flush type: 0 (default: no flush), 1 (sync flush), 2 (full flush)\n" " -w log base 2 size of history window, between 9 and 15\n", @@ -549,6 +550,7 @@ int main(int argc, char *argv[]) { FILE *in = NULL; unsigned char *compressbuf, *decompbuf, *filebuf; + char *outfile = NULL; int i, c, ret = 0; uint64_t decompbuf_size, compressbuf_size; uint64_t block_count; @@ -647,6 +649,9 @@ int main(int argc, char *argv[]) if (info.hist_bits > 15 || info.hist_bits < 9) usage(); break; + case 'o': + outfile = optarg; + break; case 'h': default: usage(); @@ -764,6 +769,13 @@ int main(int argc, char *argv[]) print_deflate_perf_line(&info); printf("\n"); + if (outfile != NULL && i + 1 == compression_queue_size) { + FILE *out; + out = fopen(outfile, "wb"); + fwrite(compressbuf, 1, info.deflate_size, out); + fclose(out); + } + if (info.inflate_time == 0) continue;