VirtualBox

Changeset 23512 in vbox for trunk


Ignore:
Timestamp:
Oct 2, 2009 12:30:26 PM (15 years ago)
Author:
vboxsync
Message:

tstCompressionBenchmark: Page by page CRC/Hash benchmarking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/testcase/tstCompressionBenchmark.cpp

    r23511 r23512  
    11/* $Id$ */
    22/** @file
    3  * Compression Benchmark for SSM.
     3 * Compression Benchmark for SSM and PGM.
    44 */
    55
     
    8787}
    8888
     89
    8990/**
    90  * Benchmark RTCrc routines potentially relevant for SSM.
     91 * Benchmark RTCrc routines potentially relevant for SSM or PGM - All in one go.
    9192 *
    9293 * @param  pabSrc   Pointer to the test data.
    9394 * @param  cbSrc    The size of the test data.
    9495 */
    95 static void tstBenchmarkCRCs(uint8_t const *pabSrc, size_t cbSrc)
     96static void tstBenchmarkCRCsAllInOne(uint8_t const *pabSrc, size_t cbSrc)
    9697{
    9798    RTPrintf("Algorithm     Speed                  Time      Digest\n"
     
    102103    NanoTS = RTTimeNanoTS() - NanoTS;
    103104    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    RTPrintf("CRC-32    %'9u KB/s  %'15llu ns - %08x\n", uSpeed, NanoTS, u32Crc);
    105106
    106107
     
    109110    NanoTS = RTTimeNanoTS() - NanoTS;
    110111    uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
    111     RTPrintf("CRC-64    %'9u KB/s  %'14llu ns - %016llx\n", uSpeed, NanoTS, u64Crc);
     112    RTPrintf("CRC-64    %'9u KB/s  %'15llu ns - %016llx\n", uSpeed, NanoTS, u64Crc);
    112113
    113114    NanoTS = RTTimeNanoTS();
     
    115116    NanoTS = RTTimeNanoTS() - NanoTS;
    116117    uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
    117     RTPrintf("Adler-32  %'9u KB/s  %'14llu ns - %08x\n", uSpeed, NanoTS, u32Crc);
     118    RTPrintf("Adler-32  %'9u KB/s  %'15llu ns - %08x\n", uSpeed, NanoTS, u32Crc);
    118119
    119120    NanoTS = RTTimeNanoTS();
     
    124125    char szDigest[257];
    125126    RTMd5ToString(abMd5Hash, szDigest, sizeof(szDigest));
    126     RTPrintf("MD5       %'9u KB/s  %'14llu ns - %s\n", uSpeed, NanoTS, szDigest);
     127    RTPrintf("MD5       %'9u KB/s  %'15llu ns - %s\n", uSpeed, NanoTS, szDigest);
    127128
    128129    NanoTS = RTTimeNanoTS();
     
    132133    uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
    133134    RTSha1ToString(abSha1Hash, szDigest, sizeof(szDigest));
    134     RTPrintf("SHA-1     %'9u KB/s  %'14llu ns - %s\n", uSpeed, NanoTS, szDigest);
     135    RTPrintf("SHA-1     %'9u KB/s  %'15llu ns - %s\n", uSpeed, NanoTS, szDigest);
    135136
    136137    NanoTS = RTTimeNanoTS();
     
    140141    uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
    141142    RTSha256ToString(abSha256Hash, szDigest, sizeof(szDigest));
    142     RTPrintf("SHA-256   %'9u KB/s  %'14llu ns - %s\n", uSpeed, NanoTS, szDigest);
     143    RTPrintf("SHA-256   %'9u KB/s  %'15llu ns - %s\n", uSpeed, NanoTS, szDigest);
    143144
    144145    NanoTS = RTTimeNanoTS();
     
    148149    uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
    149150    RTSha512ToString(abSha512Hash, szDigest, sizeof(szDigest));
    150     RTPrintf("SHA-512   %'9u KB/s  %'14llu ns - %s\n", uSpeed, NanoTS, szDigest);
     151    RTPrintf("SHA-512   %'9u KB/s  %'15llu ns - %s\n", uSpeed, NanoTS, szDigest);
     152}
     153
     154/**
     155 * Benchmark RTCrc routines potentially relevant for SSM or PGM - Page by page.
     156 *
     157 * @param  pabSrc   Pointer to the test data.
     158 * @param  cbSrc    The size of the test data.
     159 */
     160static void tstBenchmarkCRCsPageByPage(uint8_t const *pabSrc, size_t cbSrc)
     161{
     162    RTPrintf("Algorithm     Speed                  Time     \n"
     163             "----------------------------------------------\n");
     164
     165    size_t const cPages = cbSrc / PAGE_SIZE;
     166
     167    uint64_t NanoTS = RTTimeNanoTS();
     168    for (uint32_t iPage = 0; iPage < cPages; iPage++)
     169        RTCrc32(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE);
     170    NanoTS = RTTimeNanoTS() - NanoTS;
     171    unsigned uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
     172    RTPrintf("CRC-32    %'9u KB/s  %'15llu ns\n", uSpeed, NanoTS);
     173
     174
     175    NanoTS = RTTimeNanoTS();
     176    for (uint32_t iPage = 0; iPage < cPages; iPage++)
     177        RTCrc64(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE);
     178    NanoTS = RTTimeNanoTS() - NanoTS;
     179    uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
     180    RTPrintf("CRC-64    %'9u KB/s  %'15llu ns\n", uSpeed, NanoTS);
     181
     182    NanoTS = RTTimeNanoTS();
     183    for (uint32_t iPage = 0; iPage < cPages; iPage++)
     184        RTCrcAdler32(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE);
     185    NanoTS = RTTimeNanoTS() - NanoTS;
     186    uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
     187    RTPrintf("Adler-32  %'9u KB/s  %'15llu ns\n", uSpeed, NanoTS);
     188
     189    NanoTS = RTTimeNanoTS();
     190    uint8_t abMd5Hash[RTMD5HASHSIZE];
     191    for (uint32_t iPage = 0; iPage < cPages; iPage++)
     192        RTMd5(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, abMd5Hash);
     193    NanoTS = RTTimeNanoTS() - NanoTS;
     194    uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
     195    RTPrintf("MD5       %'9u KB/s  %'15llu ns\n", uSpeed, NanoTS);
     196
     197    NanoTS = RTTimeNanoTS();
     198    uint8_t abSha1Hash[RTSHA1_HASH_SIZE];
     199    for (uint32_t iPage = 0; iPage < cPages; iPage++)
     200        RTSha1(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, abSha1Hash);
     201    NanoTS = RTTimeNanoTS() - NanoTS;
     202    uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
     203    RTPrintf("SHA-1     %'9u KB/s  %'15llu ns\n", uSpeed, NanoTS);
     204
     205    NanoTS = RTTimeNanoTS();
     206    uint8_t abSha256Hash[RTSHA256_HASH_SIZE];
     207    for (uint32_t iPage = 0; iPage < cPages; iPage++)
     208        RTSha256(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, abSha256Hash);
     209    NanoTS = RTTimeNanoTS() - NanoTS;
     210    uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
     211    RTPrintf("SHA-256   %'9u KB/s  %'15llu ns\n", uSpeed, NanoTS);
     212
     213    NanoTS = RTTimeNanoTS();
     214    uint8_t abSha512Hash[RTSHA512_HASH_SIZE];
     215    for (uint32_t iPage = 0; iPage < cPages; iPage++)
     216        RTSha512(&pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, abSha512Hash);
     217    NanoTS = RTTimeNanoTS() - NanoTS;
     218    uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024);
     219    RTPrintf("SHA-512   %'9u KB/s  %'15llu ns\n", uSpeed, NanoTS);
    151220}
    152221
     
    178247        { "--page-file",      'f', RTGETOPT_REQ_STRING },
    179248        { "--offset",         'o', RTGETOPT_REQ_UINT64 },
    180         { "--page-offset",    'O', RTGETOPT_REQ_UINT64 },
     249        { "--help",           'h', RTGETOPT_REQ_NOTHING },
    181250    };
    182251
     
    225294                offPageFile = Val.u64 * PAGE_SIZE;
    226295                break;
     296
     297            case 'h':
     298                RTPrintf("syntax: tstCompressionBenchmark [options]\n"
     299                         "\n"
     300                         "Options:\n"
     301                         "  -h, --help\n"
     302                         "    Show this help page\n"
     303                         "  -i, --interations <num>\n"
     304                         "    The number of iterations.\n"
     305                         "  -n, --num-pages <pages>\n"
     306                         "    The number of pages.\n"
     307                         "  -c, --pages-at-a-time <pages>\n"
     308                         "    Number of pages at a time.\n"
     309                         "  -f, --page-file <filename>\n"
     310                         "    File or device to read the page from. The default\n"
     311                         "    is to generate some garbage.\n"
     312                         "  -o, --offset <file-offset>\n"
     313                         "    Offset into the page file to start reading at.\n");
     314                return 0;
    227315
    228316            default:
     
    543631     */
    544632    RTPrintf("\n"
    545              "tstCompressionBenchmark: Checksum/CRC\n");
    546     tstBenchmarkCRCs(g_pabSrc, g_cbPages);
     633             "tstCompressionBenchmark: Checksum/CRC - All In One\n");
     634    tstBenchmarkCRCsAllInOne(g_pabSrc, g_cbPages);
     635
     636    RTPrintf("\n"
     637             "tstCompressionBenchmark: Checksum/CRC - Page by Page\n");
     638    tstBenchmarkCRCsPageByPage(g_pabSrc, g_cbPages);
    547639
    548640    RTPrintf("tstCompressionBenchmark: END RESULTS\n");
    549 
    550641
    551642    return rc;
Note: See TracChangeset for help on using the changeset viewer.

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