VirtualBox

Ignore:
Timestamp:
Sep 27, 2012 8:28:59 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
80964
Message:

Main/Metrics: Host network metrics, linux only (#6345)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/testcase/tstCollector.cpp

    r38636 r43445  
    142142}
    143143
     144int testNetwork(pm::CollectorHAL *collector)
     145{
     146    pm::CollectorHints hints;
     147    uint64_t hostRxStart, hostTxStart, speedStart;
     148    uint64_t hostRxStop, hostTxStop, speedStop;
     149
     150    RTPrintf("\ntstCollector: TESTING - Network load, sleeping for 5 sec...\n");
     151
     152    int rc = collector->preCollect(hints, 0);
     153    if (RT_FAILURE(rc))
     154    {
     155        RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
     156        return 1;
     157    }
     158    rc = collector->getRawHostNetworkLoad("eth0", &hostRxStart, &hostTxStart, &speedStart);
     159    if (RT_FAILURE(rc))
     160    {
     161        RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc);
     162        return 1;
     163    }
     164
     165    RTThreadSleep(5000); // Sleep for five seconds
     166
     167    rc = collector->preCollect(hints, 0);
     168    if (RT_FAILURE(rc))
     169    {
     170        RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
     171        return 1;
     172    }
     173    rc = collector->getRawHostNetworkLoad("eth0", &hostRxStop, &hostTxStop, &speedStop);
     174    if (RT_FAILURE(rc))
     175    {
     176        RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc);
     177        return 1;
     178    }
     179    if (speedStart != speedStop)
     180        RTPrintf("tstCollector: getRawHostNetworkLoad() returned different bandwidth (%llu != %llu)\n", speedStart, speedStop);
     181    RTPrintf("tstCollector: host network speed = %llu bytes/sec (%llu mbit/sec)\n",
     182             speedStop, speedStop/(1000000/8));
     183    RTPrintf("tstCollector: host network rx    = %llu bytes/sec (%llu mbit/sec, %d %%*100)\n",
     184             (hostRxStop - hostRxStart)/5, (hostRxStop - hostRxStart)/(5000000/8),
     185             (hostRxStop - hostRxStart) * 10000 / (speedStop * 5));
     186    RTPrintf("tstCollector: host network tx    = %llu bytes/sec (%llu mbit/sec, %d %%*100)\n",
     187             (hostTxStop - hostTxStart)/5, (hostTxStop - hostTxStart)/(5000000/8),
     188             (hostTxStop - hostTxStart) * 10000 / (speedStop * 5));
     189
     190    return 0;
     191}
     192
    144193int main(int argc, char *argv[])
    145194{
     
    320369    RTPrintf("tstCollector: process mem used   = %lu kB\n", processUsed);
    321370#endif
     371#if 1
     372    rc = testNetwork(collector);
     373#endif
     374#if 0
    322375    RTPrintf("\ntstCollector: TESTING - Performance\n\n");
    323376
    324377    measurePerformance(collector, argv[0], 100);
     378#endif
    325379
    326380    delete collector;
Note: See TracChangeset for help on using the changeset viewer.

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