tstCompressionBenchmark.cpp revision 05c5026f0db24362b610bf7c6749e91daa870fb3
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync * Compression Benchmark for SSM and PGM.
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2009 Oracle Corporation
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * available from http://www.virtualbox.org. This file is free software;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * you can redistribute it and/or modify it under the terms of the GNU
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * General Public License (GPL) as published by the Free Software
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync/*******************************************************************************
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync* Header Files *
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync*******************************************************************************/
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync/*******************************************************************************
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync* Global Variables *
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync*******************************************************************************/
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync/** Buffer for the decompressed data (g_cbPages). */
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync/** Buffer for the compressed data (g_cbComprAlloc). */
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync/** The current size of the compressed data, ComprOutCallback */
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync/** The current offset into the compressed data, DecomprInCallback. */
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync/** The amount of space allocated for compressed data. */
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync * Store compressed data in the g_pabCompr buffer.
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsyncstatic DECLCALLBACK(int) ComprOutCallback(void *pvUser, const void *pvBuf, size_t cbBuf)
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync AssertReturn(g_cbCompr + cbBuf <= g_cbComprAlloc, VERR_BUFFER_OVERFLOW);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync * Read compressed data from g_pabComrp.
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsyncstatic DECLCALLBACK(int) DecomprInCallback(void *pvUser, void *pvBuf, size_t cbBuf, size_t *pcbBuf)
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync size_t cb = RT_MIN(cbBuf, g_cbCompr - g_offComprIn);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync// AssertReturn(cb > 0, VERR_EOF);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync * Benchmark RTCrc routines potentially relevant for SSM or PGM - All in one go.
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync * @param pabSrc Pointer to the test data.
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync * @param cbSrc The size of the test data.
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsyncstatic void tstBenchmarkCRCsAllInOne(uint8_t const *pabSrc, size_t cbSrc)
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync "------------------------------------------------------------------------------\n");
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync unsigned uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("CRC-32 %'9u KB/s %'15llu ns - %08x\n", uSpeed, NanoTS, u32Crc);
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("CRC-64 %'9u KB/s %'15llu ns - %016llx\n", uSpeed, NanoTS, u64Crc);
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("Adler-32 %'9u KB/s %'15llu ns - %08x\n", uSpeed, NanoTS, u32Crc);
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync RTMd5ToString(abMd5Hash, szDigest, sizeof(szDigest));
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("MD5 %'9u KB/s %'15llu ns - %s\n", uSpeed, NanoTS, szDigest);
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync RTSha1ToString(abSha1Hash, szDigest, sizeof(szDigest));
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("SHA-1 %'9u KB/s %'15llu ns - %s\n", uSpeed, NanoTS, szDigest);
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
de2620fab121f8e44964557477314fb9c834732cvboxsync RTSha256ToString(abSha256Hash, szDigest, sizeof(szDigest));
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("SHA-256 %'9u KB/s %'15llu ns - %s\n", uSpeed, NanoTS, szDigest);
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
de2620fab121f8e44964557477314fb9c834732cvboxsync RTSha512ToString(abSha512Hash, szDigest, sizeof(szDigest));
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("SHA-512 %'9u KB/s %'15llu ns - %s\n", uSpeed, NanoTS, szDigest);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync * Benchmark RTCrc routines potentially relevant for SSM or PGM - Page by page.
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync * @param pabSrc Pointer to the test data.
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync * @param cbSrc The size of the test data.
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsyncstatic void tstBenchmarkCRCsPageByPage(uint8_t const *pabSrc, size_t cbSrc)
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync "----------------------------------------------\n");
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync unsigned uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("CRC-32 %'9u KB/s %'15llu ns\n", uSpeed, NanoTS);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("CRC-64 %'9u KB/s %'15llu ns\n", uSpeed, NanoTS);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTCrcAdler32(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("Adler-32 %'9u KB/s %'15llu ns\n", uSpeed, NanoTS);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTMd5(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, abMd5Hash);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("MD5 %'9u KB/s %'15llu ns\n", uSpeed, NanoTS);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTSha1(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, abSha1Hash);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("SHA-1 %'9u KB/s %'15llu ns\n", uSpeed, NanoTS);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTSha256(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, abSha256Hash);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("SHA-256 %'9u KB/s %'15llu ns\n", uSpeed, NanoTS);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTSha512(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, abSha512Hash);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("SHA-512 %'9u KB/s %'15llu ns\n", uSpeed, NanoTS);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync/** Prints an error message and returns 1 for quick return from main use. */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * Parse arguments.
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync int rc = RTGetOptInit(&State, argc, argv, &s_aOptions[0], RT_ELEMENTS(s_aOptions), 1, 0);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (g_cPages * PAGE_SIZE * 4 / (PAGE_SIZE * 4) != g_cPages)
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync return Error("The specified page count is too high: %#x (%#llx bytes)\n", g_cPages, (uint64_t)g_cPages * PAGE_SHIFT);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync return Error("The specified page count is too low: %#x\n", g_cPages);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync return Error("The number of iterations must be 1 or higher\n");
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync return Error("The specified pages-at-a-time count is out of range: %#x\n", cPagesAtATime);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("syntax: tstCompressionBenchmark [options]\n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync "Options:\n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync " -h, --help\n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync " Show this help page\n"
05c5026f0db24362b610bf7c6749e91daa870fb3vboxsync " -i, --iterations <num>\n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync " The number of iterations.\n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync " -n, --num-pages <pages>\n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync " The number of pages.\n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync " -c, --pages-at-a-time <pages>\n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync " Number of pages at a time.\n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync " -f, --page-file <filename>\n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync " File or device to read the page from. The default\n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync " is to generate some garbage.\n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync " -o, --offset <file-offset>\n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync " Offset into the page file to start reading at.\n");
fb1975a6972d89de9e515bed0248db93f04ec9d8vboxsync RTPrintf("%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr());
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uint64_t cbTotal = (uint64_t)g_cPages * PAGE_SIZE * cIterations;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync return Error("cPages * cIterations -> overflow\n");
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * Gather the test memory.
0a4b1771da7a14215343599e285052284d773038vboxsync rc = RTFileReadAllEx(pszPageFile, offPageFile, g_cbPages, RTFILE_RDALL_O_DENY_NONE, (void **)&g_pabSrc, &cbFile);
0a4b1771da7a14215343599e285052284d773038vboxsync return Error("Error reading %zu bytes from %s at %llu: %Rrc\n", g_cbPages, pszPageFile, offPageFile, rc);
0a4b1771da7a14215343599e285052284d773038vboxsync return Error("Error reading %zu bytes from %s at %llu: got %zu bytes\n", g_cbPages, pszPageFile, offPageFile, cbFile);
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync /* Just fill it with something - warn about the low quality of the something. */
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync RTPrintf("tstCompressionBenchmark: WARNING! No input file was specified so the source\n"
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync "buffer will be filled with generated data of questionable quality.\n");
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync RTPrintf("To get real RAM on linux: sudo dd if=/dev/mem ... \n");
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync RTStrPrintf(szTmp, sizeof(szTmp), "aaaa%08Xzzzz", (uint32_t)(uintptr_t)pb);
37dea7414511e45db87a131e247d86578edbba59vboxsync g_cbComprAlloc = RT_MAX(g_cbPages * 2, 256 * PAGE_SIZE);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync g_pabCompr = (uint8_t *)RTMemAlloc(g_cbComprAlloc);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync return Error("failed to allocate memory buffers (g_cPages=%#x)\n", g_cPages);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * Double loop compressing and uncompressing the data, where the outer does
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * the specified number of iterations while the inner applies the different
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * compression algorithms.
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync /** The time spent decompressing. */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync /** The time spent compressing. */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync /** The size of the compressed data. */
0a4b1771da7a14215343599e285052284d773038vboxsync /** First error. */
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync /** The compression style: block or stream. */
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync /** Compression type. */
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync /** Compression level. */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync /** Method name. */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync const char *pszName;
0a4b1771da7a14215343599e285052284d773038vboxsync { 0, 0, 0, VINF_SUCCESS, false, RTZIPTYPE_STORE, RTZIPLEVEL_DEFAULT, "RTZip/Store" },
0a4b1771da7a14215343599e285052284d773038vboxsync { 0, 0, 0, VINF_SUCCESS, false, RTZIPTYPE_LZF, RTZIPLEVEL_DEFAULT, "RTZip/LZF" },
0a4b1771da7a14215343599e285052284d773038vboxsync/* { 0, 0, 0, VINF_SUCCESS, false, RTZIPTYPE_ZLIB, RTZIPLEVEL_DEFAULT, "RTZip/zlib" }, - slow plus it randomly hits VERR_GENERAL_FAILURE atm. */
0a4b1771da7a14215343599e285052284d773038vboxsync { 0, 0, 0, VINF_SUCCESS, true, RTZIPTYPE_STORE, RTZIPLEVEL_DEFAULT, "RTZipBlock/Store" },
0a4b1771da7a14215343599e285052284d773038vboxsync { 0, 0, 0, VINF_SUCCESS, true, RTZIPTYPE_LZF, RTZIPLEVEL_DEFAULT, "RTZipBlock/LZF" },
0a4b1771da7a14215343599e285052284d773038vboxsync { 0, 0, 0, VINF_SUCCESS, true, RTZIPTYPE_LZJB, RTZIPLEVEL_DEFAULT, "RTZipBlock/LZJB" },
0a4b1771da7a14215343599e285052284d773038vboxsync { 0, 0, 0, VINF_SUCCESS, true, RTZIPTYPE_LZO, RTZIPLEVEL_DEFAULT, "RTZipBlock/LZO" },
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * Compress it.
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync for (size_t iPage = 0; iPage < g_cPages; iPage += cPagesAtATime)
37dea7414511e45db87a131e247d86578edbba59vboxsync AssertBreakStmt(cbLeft > PAGE_SIZE * 4, aTests[j].rc = rc = VERR_BUFFER_OVERFLOW);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync size_t cbSrc = RT_MIN(g_cPages - iPage, cPagesAtATime) * PAGE_SIZE;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync rc = RTZipBlockCompress(aTests[j].enmType, aTests[j].enmLevel, 0 /*fFlags*/,
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync Error("RTZipBlockCompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync rc = RTZipCompCreate(&pZipComp, NULL, ComprOutCallback, aTests[j].enmType, aTests[j].enmLevel);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync Error("Failed to create the compressor for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync for (size_t iPage = 0; iPage < g_cPages; iPage += cPagesAtATime)
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync size_t cb = RT_MIN(g_cPages - iPage, cPagesAtATime) * PAGE_SIZE;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync Error("RTZipCompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync Error("RTZipCompFinish failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync * Decompress it.
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync for (size_t iPage = 0; iPage < g_cPages; iPage += cPagesAtATime)
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync size_t cbDst = RT_MIN(g_cPages - iPage, cPagesAtATime) * PAGE_SIZE;
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync rc = RTZipBlockDecompress(aTests[j].enmType, 0 /*fFlags*/,
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync Error("RTZipBlockDecompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync rc = RTZipDecompCreate(&pZipDecomp, NULL, DecomprInCallback);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync Error("Failed to create the decompressor for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync for (size_t iPage = 0; iPage < g_cPages; iPage += cPagesAtATime)
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync size_t cb = RT_MIN(g_cPages - iPage, cPagesAtATime) * PAGE_SIZE;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync rc = RTZipDecompress(pZipDecomp, pbDstPage, cb, NULL);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync Error("RTZipDecompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync Error("The compressed data doesn't match the source for '%s' (%#u)\n", aTests[j].pszName, j);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * Report the results.
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync RTPrintf("tstCompressionBenchmark: BEGIN RESULTS\n");
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync RTPrintf("%-20s In Out Ratio Size In Out\n", "Method");
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync RTPrintf("%.20s-----------------------------------------------------------------------------------------\n", "---------------------------------------------");
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync unsigned uComprSpeedIn = (unsigned)(cbTotalKB / (long double)aTests[j].cNanoCompr * 1000000000.0);
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync unsigned uComprSpeedOut = (unsigned)(aTests[j].cbCompr / (long double)aTests[j].cNanoCompr * 1000000000.0 / 1024);
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync unsigned uRatio = (unsigned)(aTests[j].cbCompr / cIterations * 100 / g_cbPages);
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync unsigned uDecomprSpeedIn = (unsigned)(aTests[j].cbCompr / (long double)aTests[j].cNanoDecompr * 1000000000.0 / 1024);
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync unsigned uDecomprSpeedOut = (unsigned)(cbTotalKB / (long double)aTests[j].cNanoDecompr * 1000000000.0);
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync RTPrintf("%-20s %'9u KB/s %'9u KB/s %3u%% %'11llu bytes %'9u KB/s %'9u KB/s",
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uComprSpeedIn, uComprSpeedOut, uRatio, aTests[j].cbCompr / cIterations,
0a4b1771da7a14215343599e285052284d773038vboxsync RTPrintf("%-20s: %Rrc\n", aTests[j].pszName, aTests[j].rc);
0a4b1771da7a14215343599e285052284d773038vboxsync RTPrintf("Input: %'10zu pages from '%s' starting at offset %'lld (%#llx)\n"
0a4b1771da7a14215343599e285052284d773038vboxsync " %'11zu bytes\n",
0a4b1771da7a14215343599e285052284d773038vboxsync g_cPages, pszPageFile, offPageFile, offPageFile, g_cbPages);
0a4b1771da7a14215343599e285052284d773038vboxsync RTPrintf("Input: %'10zu pages of generated rubbish %'11zu bytes\n",
37dea7414511e45db87a131e247d86578edbba59vboxsync * Count zero pages in the data set.
37dea7414511e45db87a131e247d86578edbba59vboxsync if (!ASMMemIsAllU32(&g_pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, 0))
37dea7414511e45db87a131e247d86578edbba59vboxsync RTPrintf(" %'10zu zero pages (%u %%)\n", cZeroPages, cZeroPages * 100 / g_cPages);
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync * A little extension to the test, benchmark relevant CRCs.
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync "tstCompressionBenchmark: Hash/CRC - All In One\n");
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync "tstCompressionBenchmark: Hash/CRC - Page by Page\n");
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync "tstCompressionBenchmark: Hash/CRC - Zero Page Digest\n");
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync "tstCompressionBenchmark: Hash/CRC - Zero Half Page Digest\n");
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync tstBenchmarkCRCsAllInOne(s_abZeroPg, PAGE_SIZE / 2);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("tstCompressionBenchmark: END RESULTS\n");