VirtualBox

Changeset 21840 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Jul 28, 2009 1:31:08 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
50470
Message:

tstCompressionBenchmark: More tests.

File:
1 edited

Legend:

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

    r21816 r21840  
    109109        { "--page-at-a-time", 'c', RTGETOPT_REQ_UINT32 },
    110110        { "--page-file",      'f', RTGETOPT_REQ_STRING },
     111        { "--offset",         'o', RTGETOPT_REQ_UINT64 },
     112        { "--page-offset",    'O', RTGETOPT_REQ_UINT64 },
    111113    };
    112114
    113115    const char     *pszPageFile = NULL;
     116    uint64_t        offPageFile = 0;
    114117    uint32_t        cIterations = 1;
    115118    uint32_t        cPagesAtATime = 1;
     
    145148            case 'f':
    146149                pszPageFile = Val.psz;
     150                break;
     151
     152            case 'o':
     153                offPageFile = Val.u64;
     154                break;
     155
     156            case 'O':
     157                offPageFile = Val.u64 * PAGE_SIZE;
    147158                break;
    148159
     
    179190    {
    180191        size_t cbFile;
    181         rc = RTFileReadAllEx(pszPageFile, 0, g_cbPages, RTFILE_RDALL_O_DENY_NONE, (void **)&g_pabSrc, &cbFile);
     192        rc = RTFileReadAllEx(pszPageFile, offPageFile, g_cbPages, RTFILE_RDALL_O_DENY_NONE, (void **)&g_pabSrc, &cbFile);
    182193        if (RT_FAILURE(rc))
    183             return Error("Error reading %zu bytes from %s: %Rrc\n", g_cbPages, pszPageFile, rc);
     194            return Error("Error reading %zu bytes from %s at %llu: %Rrc\n", g_cbPages, pszPageFile, offPageFile, rc);
    184195        if (cbFile != g_cbPages)
    185             return Error("Error reading %zu bytes from %s: got %zu bytes\n", g_cbPages, pszPageFile, cbFile);
     196            return Error("Error reading %zu bytes from %s at %llu: got %zu bytes\n", g_cbPages, pszPageFile, offPageFile, cbFile);
    186197    }
    187198    else
     
    226237        /** The size of the compressed data. */
    227238        uint64_t    cbCompr;
    228         /** Number of errrors. */
    229         uint32_t    cErrors;
     239        /** First error. */
     240        int         rc;
    230241        /** The compression style: block or stream. */
    231242        bool        fBlock;
     
    238249    } aTests[] =
    239250    {
    240         { 0, 0, 0, 0, false, RTZIPTYPE_STORE, RTZIPLEVEL_DEFAULT, "RTZip/Store" },
    241         { 0, 0, 0, 0, false, RTZIPTYPE_LZF,   RTZIPLEVEL_DEFAULT, "RTZip/LZF"   },
    242 //        { 0, 0, 0, 0, false, RTZIPTYPE_ZLIB,  RTZIPLEVEL_DEFAULT, "RTZip/zlib"  }, - slow plus it randomly hits VERR_GENERAL_FAILURE atm.
    243         { 0, 0, 0, 0, true, RTZIPTYPE_STORE,  RTZIPLEVEL_DEFAULT, "RTZipBlock/Store" },
    244         { 0, 0, 0, 0, true, RTZIPTYPE_LZF,    RTZIPLEVEL_DEFAULT, "RTZipBlock/LZF" },
    245 //        { 0, 0, 0, 0, true, RTZIPTYPE_LZJB,   RTZIPLEVEL_DEFAULT, "RTZipBlock/LZJB" },
     251        { 0, 0, 0, VINF_SUCCESS, false, RTZIPTYPE_STORE, RTZIPLEVEL_DEFAULT, "RTZip/Store"      },
     252        { 0, 0, 0, VINF_SUCCESS, false, RTZIPTYPE_LZF,   RTZIPLEVEL_DEFAULT, "RTZip/LZF"        },
     253/*      { 0, 0, 0, VINF_SUCCESS, false, RTZIPTYPE_ZLIB,  RTZIPLEVEL_DEFAULT, "RTZip/zlib"       }, - slow plus it randomly hits VERR_GENERAL_FAILURE atm. */
     254        { 0, 0, 0, VINF_SUCCESS, true,  RTZIPTYPE_STORE, RTZIPLEVEL_DEFAULT, "RTZipBlock/Store" },
     255        { 0, 0, 0, VINF_SUCCESS, true,  RTZIPTYPE_LZF,   RTZIPLEVEL_DEFAULT, "RTZipBlock/LZF"   },
     256        { 0, 0, 0, VINF_SUCCESS, true,  RTZIPTYPE_LZJB,  RTZIPLEVEL_DEFAULT, "RTZipBlock/LZJB"  },
     257        { 0, 0, 0, VINF_SUCCESS, true,  RTZIPTYPE_LZO,   RTZIPLEVEL_DEFAULT, "RTZipBlock/LZO"   },
    246258    };
    247259    RTPrintf("tstCompressionBenchmark: TESTING..");
     
    250262        for (uint32_t j = 0; j < RT_ELEMENTS(aTests); j++)
    251263        {
     264            if (RT_FAILURE(aTests[j].rc))
     265                continue;
    252266            memset(g_pabCompr,   0, g_cbComprAlloc);
    253267            memset(g_pabDecompr, 0, g_cbPages);
     
    279293                    {
    280294                        Error("RTZipBlockCompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
    281                         aTests[j].cErrors++;
     295                        aTests[j].rc = rc;
    282296                        break;
    283297                    }
     
    298312                {
    299313                    Error("Failed to create the compressor for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
    300                     aTests[j].cErrors++;
     314                    aTests[j].rc = rc;
    301315                    continue;
    302316                }
     
    310324                    {
    311325                        Error("RTZipCompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
    312                         aTests[j].cErrors++;
     326                        aTests[j].rc = rc;
    313327                        break;
    314328                    }
     
    321335                {
    322336                    Error("RTZipCompFinish failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
    323                     aTests[j].cErrors++;
     337                    aTests[j].rc = rc;
    324338                    break;
    325339                }
     
    351365                    {
    352366                        Error("RTZipBlockDecompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
    353                         aTests[j].cErrors++;
     367                        aTests[j].rc = rc;
    354368                        break;
    355369                    }
     
    368382                {
    369383                    Error("Failed to create the decompressor for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
    370                     aTests[j].cErrors++;
     384                    aTests[j].rc = rc;
    371385                    continue;
    372386                }
     
    380394                    {
    381395                        Error("RTZipDecompress failed for '%s' (#%u): %Rrc\n", aTests[j].pszName, j, rc);
    382                         aTests[j].cErrors++;
     396                        aTests[j].rc = rc;
    383397                        break;
    384398                    }
     
    395409            {
    396410                Error("The compressed data doesn't match the source for '%s' (%#u)\n", aTests[j].pszName, j);
    397                 aTests[j].cErrors++;
     411                aTests[j].rc = VERR_BAD_EXE_FORMAT;
    398412                continue;
    399413            }
     
    413427    for (uint32_t j = 0; j < RT_ELEMENTS(aTests); j++)
    414428    {
    415         if (!aTests[j].cErrors)
     429        if (RT_SUCCESS(aTests[j].rc))
    416430        {
    417431            unsigned uComprSpeedIn    = (unsigned)(cbTotalKB         / (long double)aTests[j].cNanoCompr   * 1000000000.0);
     
    434448        else
    435449        {
    436             RTPrintf("%-20s: %u errors\n", aTests[j].pszName, aTests[j].cErrors);
     450            RTPrintf("%-20s: %Rrc\n", aTests[j].pszName, aTests[j].rc);
    437451            rc = 1;
    438452        }
    439453    }
    440     RTPrintf("Input: %'12zu pages                                  (%'zu bytes)\n", g_cPages, g_cbPages);
     454    if (pszPageFile)
     455        RTPrintf("Input: %'10zu pages from '%s' starting at offset %'lld (%#llx)\n"
     456                 "                                                           %'11zu bytes\n",
     457                 g_cPages, pszPageFile, offPageFile, offPageFile, g_cbPages);
     458    else
     459        RTPrintf("Input: %'10zu pages of generated rubbish               %'11zu bytes\n",
     460                 g_cPages, g_cbPages);
    441461    RTPrintf("tstCompressionBenchmark: END RESULTS\n");
    442462
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