- Timestamp:
- Oct 2, 2009 12:30:26 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/testcase/tstCompressionBenchmark.cpp
r23511 r23512 1 1 /* $Id$ */ 2 2 /** @file 3 * Compression Benchmark for SSM .3 * Compression Benchmark for SSM and PGM. 4 4 */ 5 5 … … 87 87 } 88 88 89 89 90 /** 90 * Benchmark RTCrc routines potentially relevant for SSM .91 * Benchmark RTCrc routines potentially relevant for SSM or PGM - All in one go. 91 92 * 92 93 * @param pabSrc Pointer to the test data. 93 94 * @param cbSrc The size of the test data. 94 95 */ 95 static void tstBenchmarkCRCs (uint8_t const *pabSrc, size_t cbSrc)96 static void tstBenchmarkCRCsAllInOne(uint8_t const *pabSrc, size_t cbSrc) 96 97 { 97 98 RTPrintf("Algorithm Speed Time Digest\n" … … 102 103 NanoTS = RTTimeNanoTS() - NanoTS; 103 104 unsigned uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024); 104 RTPrintf("CRC-32 %'9u KB/s %'1 4llu ns - %08x\n", uSpeed, NanoTS, u32Crc);105 RTPrintf("CRC-32 %'9u KB/s %'15llu ns - %08x\n", uSpeed, NanoTS, u32Crc); 105 106 106 107 … … 109 110 NanoTS = RTTimeNanoTS() - NanoTS; 110 111 uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024); 111 RTPrintf("CRC-64 %'9u KB/s %'1 4llu ns - %016llx\n", uSpeed, NanoTS, u64Crc);112 RTPrintf("CRC-64 %'9u KB/s %'15llu ns - %016llx\n", uSpeed, NanoTS, u64Crc); 112 113 113 114 NanoTS = RTTimeNanoTS(); … … 115 116 NanoTS = RTTimeNanoTS() - NanoTS; 116 117 uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024); 117 RTPrintf("Adler-32 %'9u KB/s %'1 4llu ns - %08x\n", uSpeed, NanoTS, u32Crc);118 RTPrintf("Adler-32 %'9u KB/s %'15llu ns - %08x\n", uSpeed, NanoTS, u32Crc); 118 119 119 120 NanoTS = RTTimeNanoTS(); … … 124 125 char szDigest[257]; 125 126 RTMd5ToString(abMd5Hash, szDigest, sizeof(szDigest)); 126 RTPrintf("MD5 %'9u KB/s %'1 4llu ns - %s\n", uSpeed, NanoTS, szDigest);127 RTPrintf("MD5 %'9u KB/s %'15llu ns - %s\n", uSpeed, NanoTS, szDigest); 127 128 128 129 NanoTS = RTTimeNanoTS(); … … 132 133 uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024); 133 134 RTSha1ToString(abSha1Hash, szDigest, sizeof(szDigest)); 134 RTPrintf("SHA-1 %'9u KB/s %'1 4llu ns - %s\n", uSpeed, NanoTS, szDigest);135 RTPrintf("SHA-1 %'9u KB/s %'15llu ns - %s\n", uSpeed, NanoTS, szDigest); 135 136 136 137 NanoTS = RTTimeNanoTS(); … … 140 141 uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024); 141 142 RTSha256ToString(abSha256Hash, szDigest, sizeof(szDigest)); 142 RTPrintf("SHA-256 %'9u KB/s %'1 4llu ns - %s\n", uSpeed, NanoTS, szDigest);143 RTPrintf("SHA-256 %'9u KB/s %'15llu ns - %s\n", uSpeed, NanoTS, szDigest); 143 144 144 145 NanoTS = RTTimeNanoTS(); … … 148 149 uSpeed = (unsigned)(cbSrc / (long double)NanoTS * 1000000000.0 / 1024); 149 150 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 */ 160 static 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); 151 220 } 152 221 … … 178 247 { "--page-file", 'f', RTGETOPT_REQ_STRING }, 179 248 { "--offset", 'o', RTGETOPT_REQ_UINT64 }, 180 { "-- page-offset", 'O', RTGETOPT_REQ_UINT64},249 { "--help", 'h', RTGETOPT_REQ_NOTHING }, 181 250 }; 182 251 … … 225 294 offPageFile = Val.u64 * PAGE_SIZE; 226 295 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; 227 315 228 316 default: … … 543 631 */ 544 632 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); 547 639 548 640 RTPrintf("tstCompressionBenchmark: END RESULTS\n"); 549 550 641 551 642 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.