int main(){ std::cout << std::endl; { std::array<int,SIZE/1000> myArray; measurePerformance(myArray,"std::array<int,SIZE/1000>"); } { std::vector<int> myVec(SIZE); measurePerformance(myVec,"std::vector<int>(SIZE)"); } { std::deque<int>myDec(SIZE); measurePerformance(myDec,"std::deque<int>(SIZE)"); } { std::list<int>myList(SIZE); measurePerformance(myList,"std::list<int>(SIZE)"); } { std::forward_list<int>myForwardList(SIZE); measurePerformance(myForwardList,"std::forward_list<int>(SIZE)"); } { std::string myString(SIZE,' '); measurePerformance(myString,"std::string(SIZE,' ')"); } std::vector<int> tmpVec(SIZE); std::iota(tmpVec.begin(),tmpVec.end(),0); { std::set<int>mySet(tmpVec.begin(),tmpVec.end()); measurePerformance(mySet,"std::set<int>"); } { std::unordered_set<int>myUnorderedSet(tmpVec.begin(),tmpVec.end()); measurePerformance(myUnorderedSet,"std::unordered_set<int>"); } { std::map<int,int>myMap; for (auto i= 0; i <= SIZE; ++i) myMap[i]= i; measurePerformance(myMap,"std::map<int,int>"); } { std::unordered_map<int,int>myUnorderedMap; for (auto i= 0; i <= SIZE; ++i) myUnorderedMap[i]= i; measurePerformance(myUnorderedMap,"std::unordered_map<int,int>"); } }
void OpenCLWaveSimulation::render() { checkGLError(__FILE__,__LINE__); measurePerformance(); updateScene(m_fpsChronometer.getPassedTimeSinceStart()); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBindVertexArray(m_vaoWaves); glDrawElements(GL_TRIANGLES, 3 * m_waves.triangleCount(), GL_UNSIGNED_INT, ((GLubyte*)NULL + (0))); glutSwapBuffers(); }
float CoarseAltitude::update(float timestep, float depth, float desired_depth) { bool in_corridor = isInCorridor(depth, desired_depth); if (!m_tracking) { if (!in_corridor) { m_depth_ref = desired_depth; return m_depth_ref; } m_tracking = true; m_last_check = 0.0; } // count time outside current corridor if (!in_corridor) m_toutside_curr += timestep; // count time outside tighter corridor (if any) if (m_corridor) { if (!isInCorridor(depth, desired_depth, m_corridor - 1)) m_toutside_tighter += timestep; } m_last_check += timestep; // check if we need to change corridor measurePerformance(); m_since_last += timestep; if (m_since_last > 1.0 / (float)m_args->sample_limit) { m_since_last = 0.0; m_mmav->update(desired_depth); m_depth_ref = m_mmav->mean(m_corridor); } return m_depth_ref; }
int main(int argc, char *argv[]) { /* * Initialize the VBox runtime without loading * the support driver. */ int rc = RTR3InitExe(argc, &argv, 0); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: RTR3InitExe() -> %d\n", rc); return 1; } if (argc > 1 && !strcmp(argv[1], "-child")) { /* We have spawned ourselves as a child process -- scratch the leg */ RTThreadSleep(1000000); return 1; } #ifdef RT_OS_WINDOWS HRESULT hRes = CoInitialize(NULL); /* * Need to initialize security to access performance enumerators. */ hRes = CoInitializeSecurity( NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, 0); #endif pm::CollectorHAL *collector = pm::createHAL(); if (!collector) { RTPrintf("tstCollector: createMetricFactory() failed\n", rc); return 1; } #if 1 pm::CollectorHints hints; hints.collectHostCpuLoad(); hints.collectHostRamUsage(); hints.collectProcessCpuLoad(RTProcSelf()); hints.collectProcessRamUsage(RTProcSelf()); uint64_t start; uint64_t hostUserStart, hostKernelStart, hostIdleStart; uint64_t hostUserStop, hostKernelStop, hostIdleStop, hostTotal; uint64_t processUserStart, processKernelStart, processTotalStart; uint64_t processUserStop, processKernelStop, processTotalStop; RTPrintf("tstCollector: TESTING - CPU load, sleeping for 5 sec\n"); rc = collector->preCollect(hints, 0); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc); return 1; } rc = collector->getRawHostCpuLoad(&hostUserStart, &hostKernelStart, &hostIdleStart); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc); return 1; } rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStart, &processKernelStart, &processTotalStart); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc); return 1; } RTThreadSleep(5000); // Sleep for 5 seconds rc = collector->preCollect(hints, 0); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc); return 1; } rc = collector->getRawHostCpuLoad(&hostUserStop, &hostKernelStop, &hostIdleStop); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc); return 1; } rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStop, &processKernelStop, &processTotalStop); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc); return 1; } hostTotal = hostUserStop - hostUserStart + hostKernelStop - hostKernelStart + hostIdleStop - hostIdleStart; /*printf("tstCollector: host cpu user = %f sec\n", (hostUserStop - hostUserStart) / 10000000.); printf("tstCollector: host cpu kernel = %f sec\n", (hostKernelStop - hostKernelStart) / 10000000.); printf("tstCollector: host cpu idle = %f sec\n", (hostIdleStop - hostIdleStart) / 10000000.); printf("tstCollector: host cpu total = %f sec\n", hostTotal / 10000000.);*/ RTPrintf("tstCollector: host cpu user = %u.%u %%\n", (unsigned)((hostUserStop - hostUserStart) * 100 / hostTotal), (unsigned)((hostUserStop - hostUserStart) * 10000 / hostTotal % 100)); RTPrintf("tstCollector: host cpu kernel = %u.%u %%\n", (unsigned)((hostKernelStop - hostKernelStart) * 100 / hostTotal), (unsigned)((hostKernelStop - hostKernelStart) * 10000 / hostTotal % 100)); RTPrintf("tstCollector: host cpu idle = %u.%u %%\n", (unsigned)((hostIdleStop - hostIdleStart) * 100 / hostTotal), (unsigned)((hostIdleStop - hostIdleStart) * 10000 / hostTotal % 100)); RTPrintf("tstCollector: process cpu user = %u.%u %%\n", (unsigned)((processUserStop - processUserStart) * 100 / (processTotalStop - processTotalStart)), (unsigned)((processUserStop - processUserStart) * 10000 / (processTotalStop - processTotalStart) % 100)); RTPrintf("tstCollector: process cpu kernel = %u.%u %%\n\n", (unsigned)((processKernelStop - processKernelStart) * 100 / (processTotalStop - processTotalStart)), (unsigned)((processKernelStop - processKernelStart) * 10000 / (processTotalStop - processTotalStart) % 100)); RTPrintf("tstCollector: TESTING - CPU load, looping for 5 sec\n"); rc = collector->preCollect(hints, 0); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc); return 1; } rc = collector->getRawHostCpuLoad(&hostUserStart, &hostKernelStart, &hostIdleStart); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc); return 1; } rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStart, &processKernelStart, &processTotalStart); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc); return 1; } start = RTTimeMilliTS(); while(RTTimeMilliTS() - start < 5000) ; // Loop for 5 seconds rc = collector->preCollect(hints, 0); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc); return 1; } rc = collector->getRawHostCpuLoad(&hostUserStop, &hostKernelStop, &hostIdleStop); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc); return 1; } rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStop, &processKernelStop, &processTotalStop); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc); return 1; } hostTotal = hostUserStop - hostUserStart + hostKernelStop - hostKernelStart + hostIdleStop - hostIdleStart; RTPrintf("tstCollector: host cpu user = %u.%u %%\n", (unsigned)((hostUserStop - hostUserStart) * 100 / hostTotal), (unsigned)((hostUserStop - hostUserStart) * 10000 / hostTotal % 100)); RTPrintf("tstCollector: host cpu kernel = %u.%u %%\n", (unsigned)((hostKernelStop - hostKernelStart) * 100 / hostTotal), (unsigned)((hostKernelStop - hostKernelStart) * 10000 / hostTotal % 100)); RTPrintf("tstCollector: host cpu idle = %u.%u %%\n", (unsigned)((hostIdleStop - hostIdleStart) * 100 / hostTotal), (unsigned)((hostIdleStop - hostIdleStart) * 10000 / hostTotal % 100)); RTPrintf("tstCollector: process cpu user = %u.%u %%\n", (unsigned)((processUserStop - processUserStart) * 100 / (processTotalStop - processTotalStart)), (unsigned)((processUserStop - processUserStart) * 10000 / (processTotalStop - processTotalStart) % 100)); RTPrintf("tstCollector: process cpu kernel = %u.%u %%\n\n", (unsigned)((processKernelStop - processKernelStart) * 100 / (processTotalStop - processTotalStart)), (unsigned)((processKernelStop - processKernelStart) * 10000 / (processTotalStop - processTotalStart) % 100)); RTPrintf("tstCollector: TESTING - Memory usage\n"); ULONG total, used, available, processUsed; rc = collector->getHostMemoryUsage(&total, &used, &available); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: getHostMemoryUsage() -> %Rrc\n", rc); return 1; } rc = collector->getProcessMemoryUsage(RTProcSelf(), &processUsed); if (RT_FAILURE(rc)) { RTPrintf("tstCollector: getProcessMemoryUsage() -> %Rrc\n", rc); return 1; } RTPrintf("tstCollector: host mem total = %lu kB\n", total); RTPrintf("tstCollector: host mem used = %lu kB\n", used); RTPrintf("tstCollector: host mem available = %lu kB\n", available); RTPrintf("tstCollector: process mem used = %lu kB\n\n", processUsed); #endif #if 1 rc = testNetwork(collector); #endif #if 1 rc = testFsUsage(collector); #endif #if 1 rc = testDisk(collector); #endif #if 1 RTPrintf("tstCollector: TESTING - Performance\n\n"); measurePerformance(collector, argv[0], 100); #endif delete collector; printf ("\ntstCollector FINISHED.\n"); return rc; }