tstCompressionBenchmark.cpp revision 05c5026f0db24362b610bf7c6749e91daa870fb3
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync/* $Id$ */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync/** @file
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync * Compression Benchmark for SSM and PGM.
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync/*
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2009 Oracle Corporation
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync *
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
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync/*******************************************************************************
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync* Header Files *
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync*******************************************************************************/
37dea7414511e45db87a131e247d86578edbba59vboxsync#include <iprt/asm.h>
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync#include <iprt/assert.h>
fb1975a6972d89de9e515bed0248db93f04ec9d8vboxsync#include <iprt/buildconfig.h>
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync#include <iprt/crc.h>
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync#include <iprt/ctype.h>
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync#include <iprt/err.h>
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync#include <iprt/file.h>
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync#include <iprt/getopt.h>
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync#include <iprt/initterm.h>
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync#include <iprt/md5.h>
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync#include <iprt/sha.h>
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync#include <iprt/mem.h>
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync#include <iprt/param.h>
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync#include <iprt/stream.h>
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync#include <iprt/string.h>
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync#include <iprt/time.h>
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync#include <iprt/zip.h>
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync/*******************************************************************************
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync* Global Variables *
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync*******************************************************************************/
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsyncstatic size_t g_cPages = 20*_1M / PAGE_SIZE;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsyncstatic size_t g_cbPages;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsyncstatic uint8_t *g_pabSrc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync/** Buffer for the decompressed data (g_cbPages). */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsyncstatic uint8_t *g_pabDecompr;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync/** Buffer for the compressed data (g_cbComprAlloc). */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsyncstatic uint8_t *g_pabCompr;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync/** The current size of the compressed data, ComprOutCallback */
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsyncstatic size_t g_cbCompr;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync/** The current offset into the compressed data, DecomprInCallback. */
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsyncstatic size_t g_offComprIn;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync/** The amount of space allocated for compressed data. */
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsyncstatic size_t g_cbComprAlloc;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync/**
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync * Store compressed data in the g_pabCompr buffer.
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsyncstatic DECLCALLBACK(int) ComprOutCallback(void *pvUser, const void *pvBuf, size_t cbBuf)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync{
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync AssertReturn(g_cbCompr + cbBuf <= g_cbComprAlloc, VERR_BUFFER_OVERFLOW);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync memcpy(&g_pabCompr[g_cbCompr], pvBuf, cbBuf);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync g_cbCompr += cbBuf;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync return VINF_SUCCESS;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync}
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync/**
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync * Read compressed data from g_pabComrp.
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync */
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsyncstatic DECLCALLBACK(int) DecomprInCallback(void *pvUser, void *pvBuf, size_t cbBuf, size_t *pcbBuf)
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync{
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync size_t cb = RT_MIN(cbBuf, g_cbCompr - g_offComprIn);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (pcbBuf)
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync *pcbBuf = cb;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync// AssertReturn(cb > 0, VERR_EOF);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync memcpy(pvBuf, &g_pabCompr[g_offComprIn], cb);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync g_offComprIn += cb;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync return VINF_SUCCESS;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync}
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync/**
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync * Benchmark RTCrc routines potentially relevant for SSM or PGM - All in one go.
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync *
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync * @param pabSrc Pointer to the test data.
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync * @param cbSrc The size of the test data.
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync */
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsyncstatic void tstBenchmarkCRCsAllInOne(uint8_t const *pabSrc, size_t cbSrc)
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync{
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync RTPrintf("Algorithm Speed Time Digest\n"
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync "------------------------------------------------------------------------------\n");
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync uint64_t NanoTS = RTTimeNanoTS();
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync uint32_t u32Crc = RTCrc32(pabSrc, cbSrc);
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
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
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync NanoTS = RTTimeNanoTS();
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync uint64_t u64Crc = RTCrc64(pabSrc, cbSrc);
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
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
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync NanoTS = RTTimeNanoTS();
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync u32Crc = RTCrcAdler32(pabSrc, cbSrc);
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
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
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync NanoTS = RTTimeNanoTS();
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync uint8_t abMd5Hash[RTMD5HASHSIZE];
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync RTMd5(pabSrc, cbSrc, abMd5Hash);
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync char szDigest[257];
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync RTMd5ToString(abMd5Hash, szDigest, sizeof(szDigest));
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("MD5 %'9u KB/s %'15llu ns - %s\n", uSpeed, NanoTS, szDigest);
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync NanoTS = RTTimeNanoTS();
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync uint8_t abSha1Hash[RTSHA1_HASH_SIZE];
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync RTSha1(pabSrc, cbSrc, abSha1Hash);
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
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
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync NanoTS = RTTimeNanoTS();
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync uint8_t abSha256Hash[RTSHA256_HASH_SIZE];
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync RTSha256(pabSrc, cbSrc, abSha256Hash);
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
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
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync NanoTS = RTTimeNanoTS();
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync uint8_t abSha512Hash[RTSHA512_HASH_SIZE];
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync RTSha512(pabSrc, cbSrc, abSha512Hash);
b9abaf049879b3e65bedb36a4f2926d5047e4600vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
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}
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync/**
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync * Benchmark RTCrc routines potentially relevant for SSM or PGM - Page by page.
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync *
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync * @param pabSrc Pointer to the test data.
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync * @param cbSrc The size of the test data.
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync */
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsyncstatic void tstBenchmarkCRCsPageByPage(uint8_t const *pabSrc, size_t cbSrc)
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync{
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("Algorithm Speed Time \n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync "----------------------------------------------\n");
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync size_t const cPages = cbSrc / PAGE_SIZE;
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uint64_t NanoTS = RTTimeNanoTS();
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync for (uint32_t iPage = 0; iPage < cPages; iPage++)
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTCrc32(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync unsigned uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("CRC-32 %'9u KB/s %'15llu ns\n", uSpeed, NanoTS);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync NanoTS = RTTimeNanoTS();
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync for (uint32_t iPage = 0; iPage < cPages; iPage++)
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTCrc64(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("CRC-64 %'9u KB/s %'15llu ns\n", uSpeed, NanoTS);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync NanoTS = RTTimeNanoTS();
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync for (uint32_t iPage = 0; iPage < cPages; iPage++)
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTCrcAdler32(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("Adler-32 %'9u KB/s %'15llu ns\n", uSpeed, NanoTS);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync NanoTS = RTTimeNanoTS();
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uint8_t abMd5Hash[RTMD5HASHSIZE];
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync for (uint32_t iPage = 0; iPage < cPages; iPage++)
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTMd5(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, abMd5Hash);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("MD5 %'9u KB/s %'15llu ns\n", uSpeed, NanoTS);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync NanoTS = RTTimeNanoTS();
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uint8_t abSha1Hash[RTSHA1_HASH_SIZE];
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync for (uint32_t iPage = 0; iPage < cPages; iPage++)
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTSha1(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, abSha1Hash);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("SHA-1 %'9u KB/s %'15llu ns\n", uSpeed, NanoTS);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync NanoTS = RTTimeNanoTS();
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uint8_t abSha256Hash[RTSHA256_HASH_SIZE];
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync for (uint32_t iPage = 0; iPage < cPages; iPage++)
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTSha256(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, abSha256Hash);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("SHA-256 %'9u KB/s %'15llu ns\n", uSpeed, NanoTS);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync NanoTS = RTTimeNanoTS();
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uint8_t abSha512Hash[RTSHA512_HASH_SIZE];
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync for (uint32_t iPage = 0; iPage < cPages; iPage++)
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTSha512(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, abSha512Hash);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("SHA-512 %'9u KB/s %'15llu ns\n", uSpeed, NanoTS);
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync}
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync/** Prints an error message and returns 1 for quick return from main use. */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsyncstatic int Error(const char *pszMsgFmt, ...)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync{
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync RTStrmPrintf(g_pStdErr, "\nerror: ");
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync va_list va;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync va_start(va, pszMsgFmt);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync RTStrmPrintfV(g_pStdErr, pszMsgFmt, va);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync va_end(va);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync return 1;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync}
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsyncint main(int argc, char **argv)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync{
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync RTR3Init();
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync /*
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * Parse arguments.
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync static const RTGETOPTDEF s_aOptions[] =
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync {
05c5026f0db24362b610bf7c6749e91daa870fb3vboxsync { "--iterations", 'i', RTGETOPT_REQ_UINT32 },
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync { "--num-pages", 'n', RTGETOPT_REQ_UINT32 },
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync { "--page-at-a-time", 'c', RTGETOPT_REQ_UINT32 },
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync { "--page-file", 'f', RTGETOPT_REQ_STRING },
0a4b1771da7a14215343599e285052284d773038vboxsync { "--offset", 'o', RTGETOPT_REQ_UINT64 },
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync };
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync const char *pszPageFile = NULL;
0a4b1771da7a14215343599e285052284d773038vboxsync uint64_t offPageFile = 0;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync uint32_t cIterations = 1;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uint32_t cPagesAtATime = 1;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync RTGETOPTUNION Val;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync RTGETOPTSTATE State;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync int rc = RTGetOptInit(&State, argc, argv, &s_aOptions[0], RT_ELEMENTS(s_aOptions), 1, 0);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync AssertRCReturn(rc, 1);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync while ((rc = RTGetOpt(&State, &Val)))
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync {
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync switch (rc)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync {
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync case 'n':
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync g_cPages = Val.u32;
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 if (g_cPages < 1)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync return Error("The specified page count is too low: %#x\n", g_cPages);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync break;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync case 'i':
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync cIterations = Val.u32;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync if (cIterations < 1)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync return Error("The number of iterations must be 1 or higher\n");
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync break;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync case 'c':
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync cPagesAtATime = Val.u32;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (cPagesAtATime < 1 || cPagesAtATime > 10240)
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync return Error("The specified pages-at-a-time count is out of range: %#x\n", cPagesAtATime);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync break;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync case 'f':
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync pszPageFile = Val.psz;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync break;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
0a4b1771da7a14215343599e285052284d773038vboxsync case 'o':
0a4b1771da7a14215343599e285052284d773038vboxsync offPageFile = Val.u64;
0a4b1771da7a14215343599e285052284d773038vboxsync break;
0a4b1771da7a14215343599e285052284d773038vboxsync
0a4b1771da7a14215343599e285052284d773038vboxsync case 'O':
0a4b1771da7a14215343599e285052284d773038vboxsync offPageFile = Val.u64 * PAGE_SIZE;
0a4b1771da7a14215343599e285052284d773038vboxsync break;
0a4b1771da7a14215343599e285052284d773038vboxsync
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync case 'h':
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("syntax: tstCompressionBenchmark [options]\n"
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync "\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");
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync return 0;
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync
fb1975a6972d89de9e515bed0248db93f04ec9d8vboxsync case 'V':
fb1975a6972d89de9e515bed0248db93f04ec9d8vboxsync RTPrintf("%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr());
fb1975a6972d89de9e515bed0248db93f04ec9d8vboxsync return 0;
fb1975a6972d89de9e515bed0248db93f04ec9d8vboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync default:
fb1975a6972d89de9e515bed0248db93f04ec9d8vboxsync return RTGetOptPrintError(rc, &Val);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync }
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync }
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync g_cbPages = g_cPages * PAGE_SIZE;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uint64_t cbTotal = (uint64_t)g_cPages * PAGE_SIZE * cIterations;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uint64_t cbTotalKB = cbTotal / _1K;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (cbTotal / cIterations != g_cbPages)
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync return Error("cPages * cIterations -> overflow\n");
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync /*
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * Gather the test memory.
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync if (pszPageFile)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync {
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync size_t cbFile;
0a4b1771da7a14215343599e285052284d773038vboxsync rc = RTFileReadAllEx(pszPageFile, offPageFile, g_cbPages, RTFILE_RDALL_O_DENY_NONE, (void **)&g_pabSrc, &cbFile);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync if (RT_FAILURE(rc))
0a4b1771da7a14215343599e285052284d773038vboxsync return Error("Error reading %zu bytes from %s at %llu: %Rrc\n", g_cbPages, pszPageFile, offPageFile, rc);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (cbFile != g_cbPages)
0a4b1771da7a14215343599e285052284d773038vboxsync return Error("Error reading %zu bytes from %s at %llu: got %zu bytes\n", g_cbPages, pszPageFile, offPageFile, cbFile);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync }
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync else
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync g_pabSrc = (uint8_t *)RTMemAlloc(g_cbPages);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync if (g_pabSrc)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync {
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#ifdef RT_OS_LINUX
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync RTPrintf("To get real RAM on linux: sudo dd if=/dev/mem ... \n");
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync#endif
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync uint8_t *pb = g_pabSrc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uint8_t *pbEnd = &g_pabSrc[g_cbPages];
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync for (; pb != pbEnd; pb += 16)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync {
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync char szTmp[17];
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync RTStrPrintf(szTmp, sizeof(szTmp), "aaaa%08Xzzzz", (uint32_t)(uintptr_t)pb);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync memcpy(pb, szTmp, 16);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync }
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync }
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync }
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync g_pabDecompr = (uint8_t *)RTMemAlloc(g_cbPages);
37dea7414511e45db87a131e247d86578edbba59vboxsync g_cbComprAlloc = RT_MAX(g_cbPages * 2, 256 * PAGE_SIZE);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync g_pabCompr = (uint8_t *)RTMemAlloc(g_cbComprAlloc);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync if (!g_pabSrc || !g_pabDecompr || !g_pabCompr)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync return Error("failed to allocate memory buffers (g_cPages=%#x)\n", g_cPages);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync /*
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 */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync struct
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync {
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync /** The time spent decompressing. */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync uint64_t cNanoDecompr;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync /** The time spent compressing. */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync uint64_t cNanoCompr;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync /** The size of the compressed data. */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync uint64_t cbCompr;
0a4b1771da7a14215343599e285052284d773038vboxsync /** First error. */
0a4b1771da7a14215343599e285052284d773038vboxsync int rc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync /** The compression style: block or stream. */
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync bool fBlock;
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync /** Compression type. */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync RTZIPTYPE enmType;
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync /** Compression level. */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync RTZIPLEVEL enmLevel;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync /** Method name. */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync const char *pszName;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync } aTests[] =
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync {
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 };
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync RTPrintf("tstCompressionBenchmark: TESTING..");
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync for (uint32_t i = 0; i < cIterations; i++)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync {
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync for (uint32_t j = 0; j < RT_ELEMENTS(aTests); j++)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync {
0a4b1771da7a14215343599e285052284d773038vboxsync if (RT_FAILURE(aTests[j].rc))
0a4b1771da7a14215343599e285052284d773038vboxsync continue;
37dea7414511e45db87a131e247d86578edbba59vboxsync memset(g_pabCompr, 0xaa, g_cbComprAlloc);
37dea7414511e45db87a131e247d86578edbba59vboxsync memset(g_pabDecompr, 0xcc, g_cbPages);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync g_cbCompr = 0;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync g_offComprIn = 0;
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync RTPrintf("."); RTStrmFlush(g_pStdOut);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync /*
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * Compress it.
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync */
37dea7414511e45db87a131e247d86578edbba59vboxsync uint64_t NanoTS = RTTimeNanoTS();
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (aTests[j].fBlock)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync size_t cbLeft = g_cbComprAlloc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uint8_t const *pbSrcPage = g_pabSrc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uint8_t *pbDstPage = g_pabCompr;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync for (size_t iPage = 0; iPage < g_cPages; iPage += cPagesAtATime)
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
37dea7414511e45db87a131e247d86578edbba59vboxsync AssertBreakStmt(cbLeft > PAGE_SIZE * 4, aTests[j].rc = rc = VERR_BUFFER_OVERFLOW);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uint32_t *pcb = (uint32_t *)pbDstPage;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync pbDstPage += sizeof(uint32_t);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync cbLeft -= sizeof(uint32_t);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync size_t cbSrc = RT_MIN(g_cPages - iPage, cPagesAtATime) * PAGE_SIZE;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync size_t cbDst;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync rc = RTZipBlockCompress(aTests[j].enmType, aTests[j].enmLevel, 0 /*fFlags*/,
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync pbSrcPage, cbSrc,
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync pbDstPage, cbLeft, &cbDst);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (RT_FAILURE(rc))
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync Error("RTZipBlockCompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
0a4b1771da7a14215343599e285052284d773038vboxsync aTests[j].rc = rc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync break;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync *pcb = (uint32_t)cbDst;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync cbLeft -= cbDst;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync pbDstPage += cbDst;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync pbSrcPage += cbSrc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (RT_FAILURE(rc))
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync continue;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync g_cbCompr = pbDstPage - g_pabCompr;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync }
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync else
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync PRTZIPCOMP pZipComp;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync rc = RTZipCompCreate(&pZipComp, NULL, ComprOutCallback, aTests[j].enmType, aTests[j].enmLevel);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (RT_FAILURE(rc))
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync Error("Failed to create the compressor for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
0a4b1771da7a14215343599e285052284d773038vboxsync aTests[j].rc = rc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync continue;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uint8_t const *pbSrcPage = g_pabSrc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync for (size_t iPage = 0; iPage < g_cPages; iPage += cPagesAtATime)
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync size_t cb = RT_MIN(g_cPages - iPage, cPagesAtATime) * PAGE_SIZE;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync rc = RTZipCompress(pZipComp, pbSrcPage, cb);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (RT_FAILURE(rc))
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync Error("RTZipCompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
0a4b1771da7a14215343599e285052284d773038vboxsync aTests[j].rc = rc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync break;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync pbSrcPage += cb;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (RT_FAILURE(rc))
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync continue;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync rc = RTZipCompFinish(pZipComp);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (RT_FAILURE(rc))
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync Error("RTZipCompFinish failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
0a4b1771da7a14215343599e285052284d773038vboxsync aTests[j].rc = rc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync break;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync RTZipCompDestroy(pZipComp);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync NanoTS = RTTimeNanoTS() - NanoTS;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync aTests[j].cbCompr += g_cbCompr;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync aTests[j].cNanoCompr += NanoTS;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync /*
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync * Decompress it.
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync */
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync NanoTS = RTTimeNanoTS();
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (aTests[j].fBlock)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uint8_t const *pbSrcPage = g_pabCompr;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync size_t cbLeft = g_cbCompr;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uint8_t *pbDstPage = g_pabDecompr;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync for (size_t iPage = 0; iPage < g_cPages; iPage += cPagesAtATime)
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync size_t cbDst = RT_MIN(g_cPages - iPage, cPagesAtATime) * PAGE_SIZE;
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync size_t cbSrc = *(uint32_t *)pbSrcPage;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync pbSrcPage += sizeof(uint32_t);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync cbLeft -= sizeof(uint32_t);
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync rc = RTZipBlockDecompress(aTests[j].enmType, 0 /*fFlags*/,
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync pbSrcPage, cbSrc, &cbSrc,
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync pbDstPage, cbDst, &cbDst);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (RT_FAILURE(rc))
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync Error("RTZipBlockDecompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
0a4b1771da7a14215343599e285052284d773038vboxsync aTests[j].rc = rc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync break;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync pbDstPage += cbDst;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync cbLeft -= cbSrc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync pbSrcPage += cbSrc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync if (RT_FAILURE(rc))
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync continue;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync else
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync PRTZIPDECOMP pZipDecomp;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync rc = RTZipDecompCreate(&pZipDecomp, NULL, DecomprInCallback);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (RT_FAILURE(rc))
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync Error("Failed to create the decompressor for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
0a4b1771da7a14215343599e285052284d773038vboxsync aTests[j].rc = rc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync continue;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uint8_t *pbDstPage = g_pabDecompr;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync for (size_t iPage = 0; iPage < g_cPages; iPage += cPagesAtATime)
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync size_t cb = RT_MIN(g_cPages - iPage, cPagesAtATime) * PAGE_SIZE;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync rc = RTZipDecompress(pZipDecomp, pbDstPage, cb, NULL);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (RT_FAILURE(rc))
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync Error("RTZipDecompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
0a4b1771da7a14215343599e285052284d773038vboxsync aTests[j].rc = rc;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync break;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync pbDstPage += cb;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync RTZipDecompDestroy(pZipDecomp);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (RT_FAILURE(rc))
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync continue;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync }
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync NanoTS = RTTimeNanoTS() - NanoTS;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync aTests[j].cNanoDecompr += NanoTS;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (memcmp(g_pabDecompr, g_pabSrc, g_cbPages))
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
a4224cd855ed6df39de4f1bd46b44d43a8a3b980vboxsync Error("The compressed data doesn't match the source for '%s' (%#u)\n", aTests[j].pszName, j);
0a4b1771da7a14215343599e285052284d773038vboxsync aTests[j].rc = VERR_BAD_EXE_FORMAT;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync continue;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync }
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync }
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync if (RT_SUCCESS(rc))
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync RTPrintf("\n");
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync /*
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync * Report the results.
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync */
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync rc = 0;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync RTPrintf("tstCompressionBenchmark: BEGIN RESULTS\n");
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync RTPrintf("%-20s Compression Decompression\n", "");
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync RTPrintf("%-20s In Out Ratio Size In Out\n", "Method");
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync RTPrintf("%.20s-----------------------------------------------------------------------------------------\n", "---------------------------------------------");
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync for (uint32_t j = 0; j < RT_ELEMENTS(aTests); j++)
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync {
0a4b1771da7a14215343599e285052284d773038vboxsync if (RT_SUCCESS(aTests[j].rc))
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
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 aTests[j].pszName,
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uComprSpeedIn, uComprSpeedOut, uRatio, aTests[j].cbCompr / cIterations,
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync uDecomprSpeedIn, uDecomprSpeedOut);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync#if 0
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync RTPrintf(" [%'14llu / %'14llu ns]\n",
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync aTests[j].cNanoCompr / cIterations,
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync aTests[j].cNanoDecompr / cIterations);
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync#else
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync RTPrintf("\n");
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync#endif
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync else
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync {
0a4b1771da7a14215343599e285052284d773038vboxsync RTPrintf("%-20s: %Rrc\n", aTests[j].pszName, aTests[j].rc);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync rc = 1;
bb22cc767f84020ba4228ddf6df2654481c527f6vboxsync }
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync }
0a4b1771da7a14215343599e285052284d773038vboxsync if (pszPageFile)
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 else
0a4b1771da7a14215343599e285052284d773038vboxsync RTPrintf("Input: %'10zu pages of generated rubbish %'11zu bytes\n",
0a4b1771da7a14215343599e285052284d773038vboxsync g_cPages, g_cbPages);
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync
37dea7414511e45db87a131e247d86578edbba59vboxsync /*
37dea7414511e45db87a131e247d86578edbba59vboxsync * Count zero pages in the data set.
37dea7414511e45db87a131e247d86578edbba59vboxsync */
37dea7414511e45db87a131e247d86578edbba59vboxsync size_t cZeroPages = 0;
37dea7414511e45db87a131e247d86578edbba59vboxsync for (size_t iPage = 0; iPage < g_cPages; iPage++)
37dea7414511e45db87a131e247d86578edbba59vboxsync {
37dea7414511e45db87a131e247d86578edbba59vboxsync if (!ASMMemIsAllU32(&g_pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, 0))
37dea7414511e45db87a131e247d86578edbba59vboxsync cZeroPages++;
37dea7414511e45db87a131e247d86578edbba59vboxsync }
37dea7414511e45db87a131e247d86578edbba59vboxsync RTPrintf(" %'10zu zero pages (%u %%)\n", cZeroPages, cZeroPages * 100 / g_cPages);
37dea7414511e45db87a131e247d86578edbba59vboxsync
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync /*
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync * A little extension to the test, benchmark relevant CRCs.
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync */
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync RTPrintf("\n"
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync "tstCompressionBenchmark: Hash/CRC - All In One\n");
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync tstBenchmarkCRCsAllInOne(g_pabSrc, g_cbPages);
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("\n"
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync "tstCompressionBenchmark: Hash/CRC - Page by Page\n");
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync tstBenchmarkCRCsPageByPage(g_pabSrc, g_cbPages);
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync RTPrintf("\n"
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync "tstCompressionBenchmark: Hash/CRC - Zero Page Digest\n");
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync static uint8_t s_abZeroPg[PAGE_SIZE];
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync RT_ZERO(s_abZeroPg);
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync tstBenchmarkCRCsAllInOne(s_abZeroPg, PAGE_SIZE);
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync RTPrintf("\n"
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync "tstCompressionBenchmark: Hash/CRC - Zero Half Page Digest\n");
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync tstBenchmarkCRCsAllInOne(s_abZeroPg, PAGE_SIZE / 2);
6f08dc86c0bed9be0df1db071b1d8c2622b6da0avboxsync
8437ae69b1ead5e77c1ebcf454d69985d6d5e7f4vboxsync RTPrintf("tstCompressionBenchmark: END RESULTS\n");
db52f9932b0e3055b82e0d689e2d3a7251bcee30vboxsync
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync return rc;
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync}
a9d893999c866903a9b29cea4ba4f9a0a64bb65dvboxsync