VirtualBox

source: vbox/trunk/src/VBox/VMM/testcase/tstCompressionBenchmark.cpp@ 23510

Last change on this file since 23510 was 23510, checked in by vboxsync, 15 years ago

tstCompressionBenchmark: fixed copy&past error.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.3 KB
Line 
1/* $Id: tstCompressionBenchmark.cpp 23510 2009-10-02 12:08:08Z vboxsync $ */
2/** @file
3 * Compression Benchmark for SSM.
4 */
5
6/*
7 * Copyright (C) 2009 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#include <iprt/asm.h>
27#include <iprt/assert.h>
28#include <iprt/crc.h>
29#include <iprt/ctype.h>
30#include <iprt/err.h>
31#include <iprt/file.h>
32#include <iprt/getopt.h>
33#include <iprt/initterm.h>
34#include <iprt/md5.h>
35#include <iprt/sha.h>
36#include <iprt/mem.h>
37#include <iprt/param.h>
38#include <iprt/stream.h>
39#include <iprt/string.h>
40#include <iprt/time.h>
41#include <iprt/zip.h>
42
43
44/*******************************************************************************
45* Global Variables *
46*******************************************************************************/
47static size_t g_cPages = 20*_1M / PAGE_SIZE;
48static size_t g_cbPages;
49static uint8_t *g_pabSrc;
50
51/** Buffer for the decompressed data (g_cbPages). */
52static uint8_t *g_pabDecompr;
53
54/** Buffer for the compressed data (g_cbComprAlloc). */
55static uint8_t *g_pabCompr;
56/** The current size of the compressed data, ComprOutCallback */
57static size_t g_cbCompr;
58/** The current offset into the compressed data, DecomprInCallback. */
59static size_t g_offComprIn;
60/** The amount of space allocated for compressed data. */
61static size_t g_cbComprAlloc;
62
63
64/**
65 * Store compressed data in the g_pabCompr buffer.
66 */
67static DECLCALLBACK(int) ComprOutCallback(void *pvUser, const void *pvBuf, size_t cbBuf)
68{
69 AssertReturn(g_cbCompr + cbBuf <= g_cbComprAlloc, VERR_BUFFER_OVERFLOW);
70 memcpy(&g_pabCompr[g_cbCompr], pvBuf, cbBuf);
71 g_cbCompr += cbBuf;
72 return VINF_SUCCESS;
73}
74
75/**
76 * Read compressed data from g_pabComrp.
77 */
78static DECLCALLBACK(int) DecomprInCallback(void *pvUser, void *pvBuf, size_t cbBuf, size_t *pcbBuf)
79{
80 size_t cb = RT_MIN(cbBuf, g_cbCompr - g_offComprIn);
81 if (pcbBuf)
82 *pcbBuf = cb;
83// AssertReturn(cb > 0, VERR_EOF);
84 memcpy(pvBuf, &g_pabCompr[g_offComprIn], cb);
85 g_offComprIn += cb;
86 return VINF_SUCCESS;
87}
88
89/**
90 * Benchmark RTCrc routines potentially relevant for SSM.
91 *
92 * @param pabSrc Pointer to the test data.
93 * @param cbSrc The size of the test data.
94 */
95static void tstBenchmarkCRCs(uint8_t const *pabSrc, size_t cbSrc)
96{
97 RTPrintf("Algorithm Speed Time Digest\n"
98 "------------------------------------------------------------------------------\n");
99
100 uint64_t NanoTS = RTTimeNanoTS();
101 uint32_t u32Crc = RTCrc32(pabSrc, cbSrc);
102 NanoTS = RTTimeNanoTS() - NanoTS;
103 unsigned uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
104 RTPrintf("CRC-32 %'9u KB/s %'14llu ns - %08x\n", uSpeed, NanoTS, u32Crc);
105
106
107 NanoTS = RTTimeNanoTS();
108 uint64_t u64Crc = RTCrc64(pabSrc, cbSrc);
109 NanoTS = RTTimeNanoTS() - NanoTS;
110 uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
111 RTPrintf("CRC-64 %'9u KB/s %'14llu ns - %016llx\n", uSpeed, NanoTS, u64Crc);
112
113 NanoTS = RTTimeNanoTS();
114 u32Crc = RTCrcAdler32(pabSrc, cbSrc);
115 NanoTS = RTTimeNanoTS() - NanoTS;
116 uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
117 RTPrintf("Adler-32 %'9u KB/s %'14llu ns - %08x\n", uSpeed, NanoTS, u32Crc);
118
119 NanoTS = RTTimeNanoTS();
120 uint8_t abMd5Hash[RTMD5HASHSIZE];
121 RTMd5(pabSrc, cbSrc, abMd5Hash);
122 NanoTS = RTTimeNanoTS() - NanoTS;
123 uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
124 char szDigest[257];
125 RTMd5ToString(abMd5Hash, szDigest, sizeof(szDigest));
126 RTPrintf("MD5 %'9u KB/s %'14llu ns - %s\n", uSpeed, NanoTS, szDigest);
127
128 NanoTS = RTTimeNanoTS();
129 uint8_t abSha1Hash[RTSHA1_HASH_SIZE];
130 RTSha1(pabSrc, cbSrc, abSha1Hash);
131 NanoTS = RTTimeNanoTS() - NanoTS;
132 uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
133 RTSha1ToString(abSha1Hash, szDigest, sizeof(szDigest));
134 RTPrintf("SHA1 %'9u KB/s %'14llu ns - %s\n", uSpeed, NanoTS, szDigest);
135
136 NanoTS = RTTimeNanoTS();
137 uint8_t abSha256Hash[RTSHA256_HASH_SIZE];
138 RTSha256(pabSrc, cbSrc, abSha256Hash);
139 NanoTS = RTTimeNanoTS() - NanoTS;
140 uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
141 RTSha256ToString(abSha256Hash, szDigest, sizeof(szDigest));
142 RTPrintf("SHA256 %'9u KB/s %'14llu ns - %s\n", uSpeed, NanoTS, szDigest);
143
144 NanoTS = RTTimeNanoTS();
145 uint8_t abSha512Hash[RTSHA512_HASH_SIZE];
146 RTSha512(pabSrc, cbSrc, abSha512Hash);
147 NanoTS = RTTimeNanoTS() - NanoTS;
148 uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
149 RTSha512ToString(abSha512Hash, szDigest, sizeof(szDigest));
150 RTPrintf("SHA512 %'9u KB/s %'14llu ns - %s\n", uSpeed, NanoTS, szDigest);
151}
152
153
154/** Prints an error message and returns 1 for quick return from main use. */
155static int Error(const char *pszMsgFmt, ...)
156{
157 RTStrmPrintf(g_pStdErr, "\nerror: ");
158 va_list va;
159 va_start(va, pszMsgFmt);
160 RTStrmPrintfV(g_pStdErr, pszMsgFmt, va);
161 va_end(va);
162 return 1;
163}
164
165
166int main(int argc, char **argv)
167{
168 RTR3Init();
169
170 /*
171 * Parse arguments.
172 */
173 static const RTGETOPTDEF s_aOptions[] =
174 {
175 { "--interations", 'i', RTGETOPT_REQ_UINT32 },
176 { "--num-pages", 'n', RTGETOPT_REQ_UINT32 },
177 { "--page-at-a-time", 'c', RTGETOPT_REQ_UINT32 },
178 { "--page-file", 'f', RTGETOPT_REQ_STRING },
179 { "--offset", 'o', RTGETOPT_REQ_UINT64 },
180 { "--page-offset", 'O', RTGETOPT_REQ_UINT64 },
181 };
182
183 const char *pszPageFile = NULL;
184 uint64_t offPageFile = 0;
185 uint32_t cIterations = 1;
186 uint32_t cPagesAtATime = 1;
187 RTGETOPTUNION Val;
188 RTGETOPTSTATE State;
189 int rc = RTGetOptInit(&State, argc, argv, &s_aOptions[0], RT_ELEMENTS(s_aOptions), 1, 0);
190 AssertRCReturn(rc, 1);
191
192 while ((rc = RTGetOpt(&State, &Val)))
193 {
194 switch (rc)
195 {
196 case 'n':
197 g_cPages = Val.u32;
198 if (g_cPages * PAGE_SIZE * 4 / (PAGE_SIZE * 4) != g_cPages)
199 return Error("The specified page count is too high: %#x (%#llx bytes)\n", g_cPages, (uint64_t)g_cPages * PAGE_SHIFT);
200 if (g_cPages < 1)
201 return Error("The specified page count is too low: %#x\n", g_cPages);
202 break;
203
204 case 'i':
205 cIterations = Val.u32;
206 if (cIterations < 1)
207 return Error("The number of iterations must be 1 or higher\n");
208 break;
209
210 case 'c':
211 cPagesAtATime = Val.u32;
212 if (cPagesAtATime < 1 || cPagesAtATime > 10240)
213 return Error("The specified pages-at-a-time count is out of range: %#x\n", cPagesAtATime);
214 break;
215
216 case 'f':
217 pszPageFile = Val.psz;
218 break;
219
220 case 'o':
221 offPageFile = Val.u64;
222 break;
223
224 case 'O':
225 offPageFile = Val.u64 * PAGE_SIZE;
226 break;
227
228 default:
229 if (rc == VINF_GETOPT_NOT_OPTION)
230 Error("unknown argument: %s\n", Val.psz);
231 else if (rc > 0)
232 {
233 if (RT_C_IS_GRAPH(rc))
234 Error("unhandled option: -%c\n", rc);
235 else
236 Error("unhandled option: %d\n", rc);
237 }
238 else if (rc == VERR_GETOPT_UNKNOWN_OPTION)
239 Error("unknown option: %s\n", Val.psz);
240 else if (Val.pDef)
241 Error("%s: %Rrs\n", Val.pDef->pszLong, rc);
242 else
243 Error("%Rrs\n", rc);
244 return 1;
245 }
246 }
247
248 g_cbPages = g_cPages * PAGE_SIZE;
249 uint64_t cbTotal = (uint64_t)g_cPages * PAGE_SIZE * cIterations;
250 uint64_t cbTotalKB = cbTotal / _1K;
251 if (cbTotal / cIterations != g_cbPages)
252 return Error("cPages * cIterations -> overflow\n");
253
254 /*
255 * Gather the test memory.
256 */
257 if (pszPageFile)
258 {
259 size_t cbFile;
260 rc = RTFileReadAllEx(pszPageFile, offPageFile, g_cbPages, RTFILE_RDALL_O_DENY_NONE, (void **)&g_pabSrc, &cbFile);
261 if (RT_FAILURE(rc))
262 return Error("Error reading %zu bytes from %s at %llu: %Rrc\n", g_cbPages, pszPageFile, offPageFile, rc);
263 if (cbFile != g_cbPages)
264 return Error("Error reading %zu bytes from %s at %llu: got %zu bytes\n", g_cbPages, pszPageFile, offPageFile, cbFile);
265 }
266 else
267 {
268 g_pabSrc = (uint8_t *)RTMemAlloc(g_cbPages);
269 if (g_pabSrc)
270 {
271 /* Just fill it with something - warn about the low quality of the something. */
272 RTPrintf("tstCompressionBenchmark: WARNING! No input file was specified so the source\n"
273 "buffer will be filled with generated data of questionable quality.\n");
274#ifdef RT_OS_LINUX
275 RTPrintf("To get real RAM on linux: sudo dd if=/dev/mem ... \n");
276#endif
277 uint8_t *pb = g_pabSrc;
278 uint8_t *pbEnd = &g_pabSrc[g_cbPages];
279 for (; pb != pbEnd; pb += 16)
280 {
281 char szTmp[17];
282 RTStrPrintf(szTmp, sizeof(szTmp), "aaaa%08Xzzzz", (uint32_t)(uintptr_t)pb);
283 memcpy(pb, szTmp, 16);
284 }
285 }
286 }
287
288 g_pabDecompr = (uint8_t *)RTMemAlloc(g_cbPages);
289 g_cbComprAlloc = RT_MAX(g_cbPages * 2, 256 * PAGE_SIZE);
290 g_pabCompr = (uint8_t *)RTMemAlloc(g_cbComprAlloc);
291 if (!g_pabSrc || !g_pabDecompr || !g_pabCompr)
292 return Error("failed to allocate memory buffers (g_cPages=%#x)\n", g_cPages);
293
294 /*
295 * Double loop compressing and uncompressing the data, where the outer does
296 * the specified number of interations while the inner applies the different
297 * compression algorithms.
298 */
299 struct
300 {
301 /** The time spent decompressing. */
302 uint64_t cNanoDecompr;
303 /** The time spent compressing. */
304 uint64_t cNanoCompr;
305 /** The size of the compressed data. */
306 uint64_t cbCompr;
307 /** First error. */
308 int rc;
309 /** The compression style: block or stream. */
310 bool fBlock;
311 /** Compresstion type. */
312 RTZIPTYPE enmType;
313 /** Compresison level. */
314 RTZIPLEVEL enmLevel;
315 /** Method name. */
316 const char *pszName;
317 } aTests[] =
318 {
319 { 0, 0, 0, VINF_SUCCESS, false, RTZIPTYPE_STORE, RTZIPLEVEL_DEFAULT, "RTZip/Store" },
320 { 0, 0, 0, VINF_SUCCESS, false, RTZIPTYPE_LZF, RTZIPLEVEL_DEFAULT, "RTZip/LZF" },
321/* { 0, 0, 0, VINF_SUCCESS, false, RTZIPTYPE_ZLIB, RTZIPLEVEL_DEFAULT, "RTZip/zlib" }, - slow plus it randomly hits VERR_GENERAL_FAILURE atm. */
322 { 0, 0, 0, VINF_SUCCESS, true, RTZIPTYPE_STORE, RTZIPLEVEL_DEFAULT, "RTZipBlock/Store" },
323 { 0, 0, 0, VINF_SUCCESS, true, RTZIPTYPE_LZF, RTZIPLEVEL_DEFAULT, "RTZipBlock/LZF" },
324 { 0, 0, 0, VINF_SUCCESS, true, RTZIPTYPE_LZJB, RTZIPLEVEL_DEFAULT, "RTZipBlock/LZJB" },
325 { 0, 0, 0, VINF_SUCCESS, true, RTZIPTYPE_LZO, RTZIPLEVEL_DEFAULT, "RTZipBlock/LZO" },
326 };
327 RTPrintf("tstCompressionBenchmark: TESTING..");
328 for (uint32_t i = 0; i < cIterations; i++)
329 {
330 for (uint32_t j = 0; j < RT_ELEMENTS(aTests); j++)
331 {
332 if (RT_FAILURE(aTests[j].rc))
333 continue;
334 memset(g_pabCompr, 0xaa, g_cbComprAlloc);
335 memset(g_pabDecompr, 0xcc, g_cbPages);
336 g_cbCompr = 0;
337 g_offComprIn = 0;
338 RTPrintf("."); RTStrmFlush(g_pStdOut);
339
340 /*
341 * Compress it.
342 */
343 uint64_t NanoTS = RTTimeNanoTS();
344 if (aTests[j].fBlock)
345 {
346 size_t cbLeft = g_cbComprAlloc;
347 uint8_t const *pbSrcPage = g_pabSrc;
348 uint8_t *pbDstPage = g_pabCompr;
349 for (size_t iPage = 0; iPage < g_cPages; iPage += cPagesAtATime)
350 {
351 AssertBreakStmt(cbLeft > PAGE_SIZE * 4, aTests[j].rc = rc = VERR_BUFFER_OVERFLOW);
352 uint32_t *pcb = (uint32_t *)pbDstPage;
353 pbDstPage += sizeof(uint32_t);
354 cbLeft -= sizeof(uint32_t);
355 size_t cbSrc = RT_MIN(g_cPages - iPage, cPagesAtATime) * PAGE_SIZE;
356 size_t cbDst;
357 rc = RTZipBlockCompress(aTests[j].enmType, aTests[j].enmLevel, 0 /*fFlags*/,
358 pbSrcPage, cbSrc,
359 pbDstPage, cbLeft, &cbDst);
360 if (RT_FAILURE(rc))
361 {
362 Error("RTZipBlockCompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
363 aTests[j].rc = rc;
364 break;
365 }
366 *pcb = (uint32_t)cbDst;
367 cbLeft -= cbDst;
368 pbDstPage += cbDst;
369 pbSrcPage += cbSrc;
370 }
371 if (RT_FAILURE(rc))
372 continue;
373 g_cbCompr = pbDstPage - g_pabCompr;
374 }
375 else
376 {
377 PRTZIPCOMP pZipComp;
378 rc = RTZipCompCreate(&pZipComp, NULL, ComprOutCallback, aTests[j].enmType, aTests[j].enmLevel);
379 if (RT_FAILURE(rc))
380 {
381 Error("Failed to create the compressor for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
382 aTests[j].rc = rc;
383 continue;
384 }
385
386 uint8_t const *pbSrcPage = g_pabSrc;
387 for (size_t iPage = 0; iPage < g_cPages; iPage += cPagesAtATime)
388 {
389 size_t cb = RT_MIN(g_cPages - iPage, cPagesAtATime) * PAGE_SIZE;
390 rc = RTZipCompress(pZipComp, pbSrcPage, cb);
391 if (RT_FAILURE(rc))
392 {
393 Error("RTZipCompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
394 aTests[j].rc = rc;
395 break;
396 }
397 pbSrcPage += cb;
398 }
399 if (RT_FAILURE(rc))
400 continue;
401 rc = RTZipCompFinish(pZipComp);
402 if (RT_FAILURE(rc))
403 {
404 Error("RTZipCompFinish failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
405 aTests[j].rc = rc;
406 break;
407 }
408 RTZipCompDestroy(pZipComp);
409 }
410 NanoTS = RTTimeNanoTS() - NanoTS;
411 aTests[j].cbCompr += g_cbCompr;
412 aTests[j].cNanoCompr += NanoTS;
413
414 /*
415 * Decompress it.
416 */
417 NanoTS = RTTimeNanoTS();
418 if (aTests[j].fBlock)
419 {
420 uint8_t const *pbSrcPage = g_pabCompr;
421 size_t cbLeft = g_cbCompr;
422 uint8_t *pbDstPage = g_pabDecompr;
423 for (size_t iPage = 0; iPage < g_cPages; iPage += cPagesAtATime)
424 {
425 size_t cbDst = RT_MIN(g_cPages - iPage, cPagesAtATime) * PAGE_SIZE;
426 size_t cbSrc = *(uint32_t *)pbSrcPage;
427 pbSrcPage += sizeof(uint32_t);
428 cbLeft -= sizeof(uint32_t);
429 rc = RTZipBlockDecompress(aTests[j].enmType, 0 /*fFlags*/,
430 pbSrcPage, cbSrc, &cbSrc,
431 pbDstPage, cbDst, &cbDst);
432 if (RT_FAILURE(rc))
433 {
434 Error("RTZipBlockDecompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
435 aTests[j].rc = rc;
436 break;
437 }
438 pbDstPage += cbDst;
439 cbLeft -= cbSrc;
440 pbSrcPage += cbSrc;
441 }
442 if (RT_FAILURE(rc))
443 continue;
444 }
445 else
446 {
447 PRTZIPDECOMP pZipDecomp;
448 rc = RTZipDecompCreate(&pZipDecomp, NULL, DecomprInCallback);
449 if (RT_FAILURE(rc))
450 {
451 Error("Failed to create the decompressor for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
452 aTests[j].rc = rc;
453 continue;
454 }
455
456 uint8_t *pbDstPage = g_pabDecompr;
457 for (size_t iPage = 0; iPage < g_cPages; iPage += cPagesAtATime)
458 {
459 size_t cb = RT_MIN(g_cPages - iPage, cPagesAtATime) * PAGE_SIZE;
460 rc = RTZipDecompress(pZipDecomp, pbDstPage, cb, NULL);
461 if (RT_FAILURE(rc))
462 {
463 Error("RTZipDecompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
464 aTests[j].rc = rc;
465 break;
466 }
467 pbDstPage += cb;
468 }
469 RTZipDecompDestroy(pZipDecomp);
470 if (RT_FAILURE(rc))
471 continue;
472 }
473 NanoTS = RTTimeNanoTS() - NanoTS;
474 aTests[j].cNanoDecompr += NanoTS;
475
476 if (memcmp(g_pabDecompr, g_pabSrc, g_cbPages))
477 {
478 Error("The compressed data doesn't match the source for '%s' (%#u)\n", aTests[j].pszName, j);
479 aTests[j].rc = VERR_BAD_EXE_FORMAT;
480 continue;
481 }
482 }
483 }
484 if (RT_SUCCESS(rc))
485 RTPrintf("\n");
486
487 /*
488 * Report the results.
489 */
490 rc = 0;
491 RTPrintf("tstCompressionBenchmark: BEGIN RESULTS\n");
492 RTPrintf("%-20s Compression Decompression\n", "");
493 RTPrintf("%-20s In Out Ratio Size In Out\n", "Method");
494 RTPrintf("%.20s-----------------------------------------------------------------------------------------\n", "---------------------------------------------");
495 for (uint32_t j = 0; j < RT_ELEMENTS(aTests); j++)
496 {
497 if (RT_SUCCESS(aTests[j].rc))
498 {
499 unsigned uComprSpeedIn = (unsigned)(cbTotalKB / (long double)aTests[j].cNanoCompr * 1000000000.0);
500 unsigned uComprSpeedOut = (unsigned)(aTests[j].cbCompr / (long double)aTests[j].cNanoCompr * 1000000000.0 / 1024);
501 unsigned uRatio = (unsigned)(aTests[j].cbCompr / cIterations * 100 / g_cbPages);
502 unsigned uDecomprSpeedIn = (unsigned)(aTests[j].cbCompr / (long double)aTests[j].cNanoDecompr * 1000000000.0 / 1024);
503 unsigned uDecomprSpeedOut = (unsigned)(cbTotalKB / (long double)aTests[j].cNanoDecompr * 1000000000.0);
504 RTPrintf("%-20s %'9u KB/s %'9u KB/s %3u%% %'11llu bytes %'9u KB/s %'9u KB/s",
505 aTests[j].pszName,
506 uComprSpeedIn, uComprSpeedOut, uRatio, aTests[j].cbCompr / cIterations,
507 uDecomprSpeedIn, uDecomprSpeedOut);
508#if 0
509 RTPrintf(" [%'14llu / %'14llu ns]\n",
510 aTests[j].cNanoCompr / cIterations,
511 aTests[j].cNanoDecompr / cIterations);
512#else
513 RTPrintf("\n");
514#endif
515 }
516 else
517 {
518 RTPrintf("%-20s: %Rrc\n", aTests[j].pszName, aTests[j].rc);
519 rc = 1;
520 }
521 }
522 if (pszPageFile)
523 RTPrintf("Input: %'10zu pages from '%s' starting at offset %'lld (%#llx)\n"
524 " %'11zu bytes\n",
525 g_cPages, pszPageFile, offPageFile, offPageFile, g_cbPages);
526 else
527 RTPrintf("Input: %'10zu pages of generated rubbish %'11zu bytes\n",
528 g_cPages, g_cbPages);
529
530 /*
531 * Count zero pages in the data set.
532 */
533 size_t cZeroPages = 0;
534 for (size_t iPage = 0; iPage < g_cPages; iPage++)
535 {
536 if (!ASMMemIsAllU32(&g_pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, 0))
537 cZeroPages++;
538 }
539 RTPrintf(" %'10zu zero pages (%u %%)\n", cZeroPages, cZeroPages * 100 / g_cPages);
540
541 /*
542 * A little extension to the test, benchmark relevant CRCs.
543 */
544 RTPrintf("\n"
545 "tstCompressionBenchmark: Checksum/CRC\n");
546 tstBenchmarkCRCs(g_pabSrc, g_cbPages);
547
548 RTPrintf("tstCompressionBenchmark: END RESULTS\n");
549
550
551 return rc;
552}
553
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette