tstCompressionBenchmark.cpp revision ad27e1d5e48ca41245120c331cc88b50464813ce
* Compression Benchmark for SSM and PGM. * Copyright (C) 2009 Oracle Corporation * This file is part of VirtualBox Open Source Edition (OSE), as * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. /******************************************************************************* *******************************************************************************/ /******************************************************************************* *******************************************************************************/ /** Buffer for the decompressed data (g_cbPages). */ /** Buffer for the compressed data (g_cbComprAlloc). */ /** The current size of the compressed data, ComprOutCallback */ /** The current offset into the compressed data, DecomprInCallback. */ /** The amount of space allocated for compressed data. */ * Store compressed data in the g_pabCompr buffer. * Read compressed data from g_pabComrp. // AssertReturn(cb > 0, VERR_EOF); * Benchmark RTCrc routines potentially relevant for SSM or PGM - All in one go. * @param pabSrc Pointer to the test data. * @param cbSrc The size of the test data. RTPrintf(
"Algorithm Speed Time Digest\n" "------------------------------------------------------------------------------\n");
* Benchmark RTCrc routines potentially relevant for SSM or PGM - Page by page. * @param pabSrc Pointer to the test data. * @param cbSrc The size of the test data. "----------------------------------------------\n");
/** Prints an error message and returns 1 for quick return from main use. */ return Error(
"The specified page count is too low: %#x\n",
g_cPages);
return Error(
"The number of iterations must be 1 or higher\n");
return Error(
"The specified pages-at-a-time count is out of range: %#x\n",
cPagesAtATime);
RTPrintf(
"syntax: tstCompressionBenchmark [options]\n" " -i, --interations <num>\n" " The number of iterations.\n" " -n, --num-pages <pages>\n" " The number of pages.\n" " -c, --pages-at-a-time <pages>\n" " Number of pages at a time.\n" " -f, --page-file <filename>\n" " File or device to read the page from. The default\n" " is to generate some garbage.\n" " -o, --offset <file-offset>\n" " Offset into the page file to start reading at.\n");
return Error(
"cPages * cIterations -> overflow\n");
* Gather the test memory. /* Just fill it with something - warn about the low quality of the something. */ RTPrintf(
"tstCompressionBenchmark: WARNING! No input file was specified so the source\n" "buffer will be filled with generated data of questionable quality.\n");
return Error(
"failed to allocate memory buffers (g_cPages=%#x)\n",
g_cPages);
* Double loop compressing and uncompressing the data, where the outer does * the specified number of iterations while the inner applies the different * compression algorithms. /** The time spent decompressing. */ /** The time spent compressing. */ /** The size of the compressed data. */ /** The compression style: block or stream. */ /** Compression level. */ /* { 0, 0, 0, VINF_SUCCESS, false, RTZIPTYPE_ZLIB, RTZIPLEVEL_DEFAULT, "RTZip/zlib" }, - slow plus it randomly hits VERR_GENERAL_FAILURE atm. */ RTPrintf(
"tstCompressionBenchmark: TESTING..");
Error(
"The compressed data doesn't match the source for '%s' (%#u)\n",
aTests[j].
pszName, j);
RTPrintf(
"tstCompressionBenchmark: BEGIN RESULTS\n");
RTPrintf(
"%-20s Compression Decompression\n",
"");
RTPrintf(
"%-20s In Out Ratio Size In Out\n",
"Method");
RTPrintf(
"%.20s-----------------------------------------------------------------------------------------\n",
"---------------------------------------------");
RTPrintf(
"%-20s %'9u KB/s %'9u KB/s %3u%% %'11llu bytes %'9u KB/s %'9u KB/s",
RTPrintf(
"Input: %'10zu pages from '%s' starting at offset %'lld (%#llx)\n" RTPrintf(
"Input: %'10zu pages of generated rubbish %'11zu bytes\n",
* Count zero pages in the data set. * A little extension to the test, benchmark relevant CRCs. "tstCompressionBenchmark: Hash/CRC - All In One\n");
"tstCompressionBenchmark: Hash/CRC - Page by Page\n");
"tstCompressionBenchmark: Hash/CRC - Zero Page Digest\n");
"tstCompressionBenchmark: Hash/CRC - Zero Half Page Digest\n");
RTPrintf(
"tstCompressionBenchmark: END RESULTS\n");