VirtualBox

Ignore:
Timestamp:
Jan 14, 2019 7:18:24 AM (6 years ago)
Author:
vboxsync
Message:

ValKit/FsPerf: Started on a simple shared folders performance profiler. bugref:9172 [build fix]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/utils/fs/FsPerf.cpp

    r76796 r76801  
    8787 * Always does an even number of tree iterations.
    8888 */
    89 #define PROFILE_MANYTREE_FN(a_szPath, a_fnCall, a_cEstimationIterations, a_cNsTarget, a_szDesc1, a_szDesc2) \
     89#define PROFILE_MANYTREE_FN(a_szPath, a_fnCall, a_cEstimationIterations, a_cNsTarget, a_szDesc) \
    9090    do { \
    9191        /* Estimate how many iterations we need to fill up the given timeslot: */ \
     
    124124        } \
    125125        uint64_t const cNsElapsed = RTTimeNanoTS() - nsStart; \
    126         if (a_szDesc1 != NULL) \
    127             RTTestIValueF(cNsElapsed, RTTESTUNIT_NS, a_szDesc1, cCalls); \
    128         RTTestIValueF(cNsElapsed / cCalls, RTTESTUNIT_NS_PER_OCCURRENCE, a_szDesc2); \
     126        RTTestIValueF(cNsElapsed / cCalls, RTTESTUNIT_NS_PER_OCCURRENCE, a_szDesc); \
    129127    } while (0)
    130128
     
    428426    /* Manytree: */
    429427    char szPath[RTPATH_MAX];
    430     PROFILE_MANYTREE_FN(szPath, fsPerfOpenExistingOnceReadonly(szPath), 1, g_nsTestRun, NULL, "RTFileOpen/Close/manytree/readonly");
     428    PROFILE_MANYTREE_FN(szPath, fsPerfOpenExistingOnceReadonly(szPath), 1, g_nsTestRun, "RTFileOpen/Close/manytree/readonly");
    431429}
    432430
     
    534532    char szPath[RTPATH_MAX];
    535533    PROFILE_MANYTREE_FN(szPath, RTPathQueryInfoEx(szPath, &ObjInfo, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK),
    536                         1, g_nsTestRun, NULL, "RTPathQueryInfoEx/manytree/NOTHING");
     534                        1, g_nsTestRun, "RTPathQueryInfoEx/manytree/NOTHING");
    537535    PROFILE_MANYTREE_FN(szPath, RTPathQueryInfoEx(szPath, &ObjInfo, RTFSOBJATTRADD_UNIX, RTPATH_F_ON_LINK),
    538                         1, g_nsTestRun, NULL, "RTPathQueryInfoEx/manytree/UNIX");
     536                        1, g_nsTestRun, "RTPathQueryInfoEx/manytree/UNIX");
    539537}
    540538
     
    574572    char szPath[RTPATH_MAX];
    575573    PROFILE_MANYTREE_FN(szPath, RTPathSetMode(szPath, iIteration & 1 ? fOddMode : fEvenMode), 1, g_nsTestRun,
    576                         NULL, "RTPathSetMode/manytree");
     574                        "RTPathSetMode/manytree");
    577575    DO_MANYTREE_FN(szPath, RTPathSetMode(szPath, ObjInfo.Attr.fMode));
    578576}
     
    636634    PROFILE_MANYTREE_FN(szPath, RTPathSetTimesEx(szPath, iIteration & 1 ? &Time1 : &Time2, iIteration & 1 ? &Time2 : &Time1,
    637635                                                 NULL, NULL, RTPATH_F_ON_LINK),
    638                         1, g_nsTestRun, NULL, "RTPathSetTimesEx/manytree");
     636                        1, g_nsTestRun, "RTPathSetTimesEx/manytree");
    639637}
    640638
     
    684682
    685683    /* Manytree: */
    686     PROFILE_MANYTREE_FN(szPath, fsPerfRenameMany(szPath, iIteration), 2, g_nsTestRun, NULL, "RTPathRename/manytree");
     684    PROFILE_MANYTREE_FN(szPath, fsPerfRenameMany(szPath, iIteration), 2, g_nsTestRun, "RTPathRename/manytree");
    687685}
    688686
     
    814812     * Profile.
    815813     */
    816     PROFILE_FN(fsPerfEnumEmpty(), g_nsTestRun, "RTDirOpen/Read/Close empty");
     814    PROFILE_FN(fsPerfEnumEmpty(),     g_nsTestRun, "RTDirOpen/Read/Close empty");
    817815    PROFILE_FN(fsPerfEnumManyFiles(), g_nsTestRun, "RTDirOpen/Read/Close manyfiles");
    818816}
    819817
    820818
     819void fsPerfMkDirRmDir(void)
     820{
     821    RTTestISub("mkdir/rmdir");
     822
     823    /* Non-existing directories: */
     824    RTTESTI_CHECK_RC(RTDirRemove(InEmptyDir(RT_STR_TUPLE("no-such-dir"))), VERR_FILE_NOT_FOUND);
     825    RTTESTI_CHECK_RC(RTDirRemove(InEmptyDir(RT_STR_TUPLE("no-such-dir" RTPATH_SLASH_STR "no-such-file"))), VERR_PATH_NOT_FOUND);
     826    RTTESTI_CHECK_RC(RTDirCreate(InEmptyDir(RT_STR_TUPLE("no-such-dir" RTPATH_SLASH_STR "no-such-file")), 0755, 0), VERR_PATH_NOT_FOUND);
     827
     828    /* Already existing directories and files: */
     829    RTTESTI_CHECK_RC(RTDirCreate(InEmptyDir(RT_STR_TUPLE(".")), 0755, 0), VERR_ALREADY_EXISTS);
     830    RTTESTI_CHECK_RC(RTDirCreate(InEmptyDir(RT_STR_TUPLE("..")), 0755, 0), VERR_ALREADY_EXISTS);
     831
     832    /* Remove directory with subdirectories: */
     833    RTTESTI_CHECK_RC(RTDirRemove(InDir(RT_STR_TUPLE("."))), VERR_DIR_NOT_EMPTY);
     834
     835    /* Create a directory and remove it: */
     836    RTTESTI_CHECK_RC(RTDirCreate(InDir(RT_STR_TUPLE("subdir-1")), 0755, 0), VINF_SUCCESS);
     837    RTTESTI_CHECK_RC(RTDirRemove(g_szDir), VINF_SUCCESS);
     838
     839    /* Create a file and try remove it or create a directory with the same name: */
     840    RTFILE hFile1;
     841    RTTESTI_CHECK_RC_RETV(RTFileOpen(&hFile1, InDir(RT_STR_TUPLE("file18")),
     842                                     RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_NONE | RTFILE_O_WRITE), VINF_SUCCESS);
     843    RTTESTI_CHECK_RC(RTFileClose(hFile1), VINF_SUCCESS);
     844    RTTESTI_CHECK_RC(RTDirRemove(g_szDir), VERR_NOT_A_DIRECTORY);
     845    RTTESTI_CHECK_RC(RTDirCreate(g_szDir, 0755, 0), VERR_ALREADY_EXISTS);
     846    RTTESTI_CHECK_RC(RTDirCreate(InDir(RT_STR_TUPLE("file18" RTPATH_SLASH_STR "subdir")), 0755, 0), VERR_PATH_NOT_FOUND);
     847
     848
     849    /*
     850     * Profile alternately creating and removing a bunch of directories.
     851     */
     852    for (;;)
     853    {
     854        /* Create a bunch: */
     855
     856        /* Remove the bunch: */
     857
     858        /* Check if we got time for another round: */
     859        break;
     860    }
     861}
     862
     863
    821864void fsPerfRm(void)
    822865{
    823866    RTTestISub("rm");
    824867
     868    /* Non-existing files. */
    825869    RTTESTI_CHECK_RC(RTFileDelete(InEmptyDir(RT_STR_TUPLE("no-such-file"))), VERR_FILE_NOT_FOUND);
    826870    RTTESTI_CHECK_RC(RTFileDelete(InEmptyDir(RT_STR_TUPLE("no-such-dir" RTPATH_SLASH_STR "no-such-file"))), VERR_PATH_NOT_FOUND);
     871
     872    /* Directories: */
     873#ifdef RT_OS_WINDOWS
     874    RTTESTI_CHECK_RC(RTFileDelete(InEmptyDir(RT_STR_TUPLE("."))), VERR_ACCESS_DENIED);
     875#else
     876    RTTESTI_CHECK_RC(RTFileDelete(InEmptyDir(RT_STR_TUPLE("."))), VERR_IS_A_DIRECTORY);
     877#endif
    827878
    828879    /* Shallow: */
     
    10101061                if (RT_SUCCESS(rc))
    10111062                {
     1063                    //g_fManyFiles = false;
     1064
    10121065                    /* Do tests: */
    10131066                    if (g_fManyFiles)
     
    10231076                    fsPerfRename();
    10241077                    vsPerfDirEnum();
    1025                     /// @todo fsPerfMkDir
    1026                     /// @todo fsPerfRmDir
     1078#endif
     1079                    fsPerfMkDirRmDir();
    10271080                    /// @todo fsPerfRead
    10281081                    /// @todo fsPerfWrite
    10291082                    /// @todo fsPerfSeek
    10301083                    /// @todo fsPerfChSize
    1031 #endif
    10321084                    fsPerfRm(); /* must come last as it deletes manyfiles and manytree */
    10331085                }
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