diff --git a/OBSApi/Utility/Profiler.cpp b/OBSApi/Utility/Profiler.cpp index f112c4ad..6d2c10c1 100644 --- a/OBSApi/Utility/Profiler.cpp +++ b/OBSApi/Utility/Profiler.cpp @@ -50,6 +50,7 @@ struct BASE_EXPORT ProfileNodeInfo CTSTR lpName; DWORD numCalls; + DWORD numParallelCalls; DWORD avgTimeElapsed; DWORD avgCpuTime; double avgPercentage; @@ -70,8 +71,8 @@ struct BASE_EXPORT ProfileNodeInfo void calculateProfileData(int rootCallCount) { - avgTimeElapsed = (DWORD)(totalTimeElapsed/(QWORD)rootCallCount); - avgCpuTime = (DWORD)(cpuTimeElapsed/(QWORD)rootCallCount); + avgTimeElapsed = (DWORD)(totalTimeElapsed/(QWORD)numCalls); + avgCpuTime = (DWORD)(cpuTimeElapsed/(QWORD)numCalls); if(parent) avgPercentage = (double(avgTimeElapsed)/double(parent->avgTimeElapsed))*parent->avgPercentage; @@ -97,7 +98,10 @@ struct BASE_EXPORT ProfileNodeInfo void dumpData(int rootCallCount, int indent=0) { if(indent == 0) + { + rootCallCount = (int)floor(rootCallCount/(double)numParallelCalls+0.5); calculateProfileData(rootCallCount); + } String indentStr; for(int i=0; icpuTimeElapsed += cpuTime; info->lastCpuTimeElapsed = cpuTime; } + info->numParallelCalls = parallelCalls; } if(!bSingularNode) @@ -312,4 +319,9 @@ void ProfilerNode::MonitorThread(HANDLE thread_) return; thread = thread_; cpuStartTime = OSGetThreadTime(thread); -} \ No newline at end of file +} + +void ProfilerNode::SetParallelCallCount(DWORD num) +{ + parallelCalls = num; +} diff --git a/OBSApi/Utility/Profiler.h b/OBSApi/Utility/Profiler.h index fc763f1a..62124268 100644 --- a/OBSApi/Utility/Profiler.h +++ b/OBSApi/Utility/Profiler.h @@ -28,6 +28,7 @@ class BASE_EXPORT ProfilerNode CTSTR lpName; QWORD startTime, cpuStartTime; + DWORD parallelCalls; HANDLE thread; ProfilerNode *parent; bool bSingularNode; @@ -37,6 +38,7 @@ public: ProfilerNode(CTSTR name, bool bSingularize=false); ~ProfilerNode(); void MonitorThread(HANDLE thread); + void SetParallelCallCount(DWORD num); }; //BASE_EXPORT extern ProfilerNode *__curProfilerNode; @@ -45,11 +47,12 @@ BASE_EXPORT extern BOOL bProfilingEnabled; #define ENABLE_PROFILING 1 #ifdef ENABLE_PROFILING - #define profileSingularSegment(name) ProfilerNode _curProfiler(TEXT(name), true); - #define profileSingularIn(name) {ProfilerNode _curProfiler(TEXT(name), true); - #define profileSegment(name) ProfilerNode _curProfiler(TEXT(name)); - #define profileIn(name) {ProfilerNode _curProfiler(TEXT(name)); - #define profileOut } + #define profileSingularSegment(name) ProfilerNode _curProfiler(TEXT(name), true); + #define profileSingularIn(name) {ProfilerNode _curProfiler(TEXT(name), true); + #define profileSegment(name) ProfilerNode _curProfiler(TEXT(name)); + #define profileParallelSegment(name, num) ProfilerNode _curProfiler(TEXT(name)); _curProfiler.SetParallelCallCount(num); + #define profileIn(name) {ProfilerNode _curProfiler(TEXT(name)); + #define profileOut } #else #define profileSingularSegment(name) #define profileSingularIn(name)