VirtualBox

儲存庫 vbox 的更動 12085


忽略:
時間撮記:
2008-9-4 上午11:50:30 (16 年 以前)
作者:
vboxsync
訊息:

PerfAPI: perf tests

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Main/testcase/tstCollector.cpp

    r11822 r12085  
    3434#endif
    3535#ifdef RT_OS_WINDOWS
     36#define _WIN32_DCOM
     37#include <objidl.h>
     38#include <objbase.h>
    3639#include "../win/PerformanceWin.cpp"
    3740#endif
     
    6265    return 0;
    6366}
     67
     68#define CALLS_PER_SECOND(fn) \
     69    nCalls = 0; \
     70    start = RTTimeMilliTS(); \
     71    do { \
     72        rc = collector->fn; \
     73        ++nCalls; \
     74    } while(RTTimeMilliTS() - start < 1000); \
     75    if (RT_FAILURE(rc)) \
     76    { \
     77        RTPrintf("tstCollector: "#fn" -> %Vrc\n", rc); \
     78        return 1; \
     79    } \
     80    RTPrintf("%50s -- %u calls per second\n", #fn, nCalls)
    6481
    6582int main(int argc, char *argv[])
     
    7592        return 1;
    7693    }
     94#ifdef RT_OS_WINDOWS
     95    HRESULT hRes = CoInitialize(NULL);
     96    /*
     97     * Need to initialize security to access performance enumerators.
     98     */
     99    hRes = CoInitializeSecurity(
     100        NULL,
     101        -1,
     102        NULL,
     103        NULL,
     104        RPC_C_AUTHN_LEVEL_NONE,
     105        RPC_C_IMP_LEVEL_IMPERSONATE,
     106        NULL, EOAC_NONE, 0);
     107#endif
     108
     109    uint64_t start;
    77110
    78111    pm::CollectorHAL *collector = createCollector();
     
    82115        return 1;
    83116    }
    84 
     117#if 1
    85118    uint64_t hostUserStart, hostKernelStart, hostIdleStart;
    86119    uint64_t hostUserStop, hostKernelStop, hostIdleStop, hostTotal;
     
    140173        return 1;
    141174    }
    142     uint64_t start = RTTimeMilliTS();
     175    start = RTTimeMilliTS();
    143176    while(RTTimeMilliTS() - start < 5000); // Loop for 5 seconds
    144177    rc = collector->getRawHostCpuLoad(&hostUserStop, &hostKernelStop, &hostIdleStop);
     
    183216    RTPrintf("tstCollector: host mem available = %lu kB\n", available);
    184217    RTPrintf("tstCollector: process mem used   = %lu kB\n", processUsed);
    185 
     218#endif
     219    RTPrintf("\ntstCollector: TESTING - Performance\n\n");
     220    unsigned nCalls;
     221    ULONG tmp;
     222    uint64_t tmp64;
     223    RTPROCESS pid = RTProcSelf();
     224    /* Host CPU load */
     225    CALLS_PER_SECOND(getRawHostCpuLoad(&tmp64, &tmp64, &tmp64));
     226    /* Process CPU load */
     227    CALLS_PER_SECOND(getRawProcessCpuLoad(pid, &tmp64, &tmp64, &tmp64));
     228    /* Host CPU speed */
     229    CALLS_PER_SECOND(getHostCpuMHz(&tmp));
     230    /* Host RAM usage */
     231    CALLS_PER_SECOND(getHostMemoryUsage(&tmp, &tmp, &tmp));
     232    /* Process RAM usage */
     233    CALLS_PER_SECOND(getProcessMemoryUsage(pid, &tmp));
     234   
    186235    delete collector;
    187236
    188     printf ("tstCollector FINISHED.\n");
     237    printf ("\ntstCollector FINISHED.\n");
    189238
    190239    return rc;
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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