From aa8b51930f2250af2443a74ded5d20978dc816fe Mon Sep 17 00:00:00 2001 From: Roy Oursler Date: Wed, 13 Jun 2018 13:06:32 -0700 Subject: [PATCH] igzip: Add variable history window to perf test Change-Id: Ia5eb10094e8c84778ed6cf3a51ddade9a19103b5 Signed-off-by: Roy Oursler --- igzip/igzip_file_perf.c | 22 +++++++++++++++++++--- igzip/igzip_stateless_file_perf.c | 22 +++++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/igzip/igzip_file_perf.c b/igzip/igzip_file_perf.c index 8e8de44..0863386 100644 --- a/igzip/igzip_file_perf.c +++ b/igzip/igzip_file_perf.c @@ -106,7 +106,8 @@ int usage(void) " -b input buffer size, 0 buffers all the input\n" " -i number of iterations (at least 1)\n" " -o output file for compresed data\n" - " -d dictionary file used by compression\n"); + " -d dictionary file used by compression\n" + " -w log base 2 size of history window, between 8 and 15\n"); exit(0); } @@ -121,8 +122,9 @@ int main(int argc, char *argv[]) struct isal_hufftables hufftables_custom; int level = 0, level_size = 0, avail_in; char *in_file_name = NULL, *out_file_name = NULL, *dict_file_name = NULL; + uint32_t hist_bits = 0; - while ((c = getopt(argc, argv, "h0123456789i:b:o:d:")) != -1) { + while ((c = getopt(argc, argv, "h0123456789i:b:o:d:w:")) != -1) { if (c >= '0' && c <= '9') { if (c > '0' + ISAL_DEF_MAX_LEVEL) usage(); @@ -148,6 +150,11 @@ int main(int argc, char *argv[]) case 'b': inbuf_size = atoi(optarg); break; + case 'w': + hist_bits = atoi(optarg); + if (hist_bits > 15 || hist_bits < 8) + usage(); + break; case 'h': default: usage(); @@ -183,7 +190,14 @@ int main(int argc, char *argv[]) printf("outfile=%s\n", dict_file_name); } - printf("Window Size: %d K\n", IGZIP_HIST_SIZE / 1024); + if (hist_bits == 0) + printf("Window Size: %d K\n", IGZIP_HIST_SIZE / 1024); + + else if (hist_bits < 10) + printf("Window Size: %.2f K\n", 1.0 * (1 << hist_bits) / 1024); + else + printf("Window Size: %d K\n", (1 << hist_bits) / 1024); + printf("igzip_file_perf: \n"); fflush(0); @@ -261,6 +275,7 @@ int main(int argc, char *argv[]) stream.next_out = outbuf; stream.avail_out = outbuf_size; stream.next_in = inbuf; + stream.hist_bits = hist_bits; avail_in = infile_size; while (avail_in > 0) { @@ -304,6 +319,7 @@ int main(int argc, char *argv[]) stream.avail_out = outbuf_size; stream.next_in = inbuf; stream.hufftables = &hufftables_custom; + stream.hist_bits = hist_bits; avail_in = infile_size; while (avail_in > 0) { diff --git a/igzip/igzip_stateless_file_perf.c b/igzip/igzip_stateless_file_perf.c index 2318206..741efd7 100644 --- a/igzip/igzip_stateless_file_perf.c +++ b/igzip/igzip_stateless_file_perf.c @@ -104,7 +104,8 @@ int usage(void) " -h help\n" " -X use compression level X with 0 <= X <= 2\n" " -i number of iterations (at least 1)\n" - " -o output file for compresed data\n"); + " -o output file for compresed data\n" + " -w log base 2 size of history window, between 8 and 15\n"); exit(0); } @@ -118,8 +119,9 @@ int main(int argc, char *argv[]) struct isal_hufftables hufftables_custom; int level = 0, level_size = 0; char *in_file_name = NULL, *out_file_name = NULL; + uint32_t hist_bits = 0; - while ((c = getopt(argc, argv, "h0123456789i:o:")) != -1) { + while ((c = getopt(argc, argv, "h0123456789i:o:w:")) != -1) { if (c >= '0' && c <= '9') { if (c > '0' + ISAL_DEF_MAX_LEVEL) usage(); @@ -139,6 +141,11 @@ int main(int argc, char *argv[]) if (iterations < 1) usage(); break; + case 'w': + hist_bits = atoi(optarg); + if (hist_bits > 15 || hist_bits < 8) + usage(); + break; case 'h': default: usage(); @@ -165,7 +172,14 @@ int main(int argc, char *argv[]) printf("outfile=%s\n", out_file_name); } - printf("Window Size: %d K\n", IGZIP_HIST_SIZE / 1024); + if (hist_bits == 0) + printf("Window Size: %d K\n", IGZIP_HIST_SIZE / 1024); + + else if (hist_bits < 10) + printf("Window Size: %.2f K\n", 1.0 * (1 << hist_bits) / 1024); + else + printf("Window Size: %d K\n", (1 << hist_bits) / 1024); + printf("igzip_file_perf: \n"); fflush(0); /* Allocate space for entire input file and output @@ -222,6 +236,7 @@ int main(int argc, char *argv[]) stream.level = level; stream.level_buf = level_buf; stream.level_buf_size = level_size; + stream.hist_bits = hist_bits; isal_deflate_stateless(&stream); if (stream.avail_in != 0) break; @@ -253,6 +268,7 @@ int main(int argc, char *argv[]) stream.level_buf = level_buf; stream.level_buf_size = level_size; stream.hufftables = &hufftables_custom; + stream.hist_bits = hist_bits; isal_deflate_stateless(&stream); printf(" ratio_custom=%3.1f%%", 100.0 * stream.total_out / infile_size);