Index: src/libchengine/TSubTaskArray.cpp =================================================================== diff -u -r08717141ce5f6926116c298cbc9442094a45bb67 -r178e776294cbc8e3a5a33b355a314e0db94b214b --- src/libchengine/TSubTaskArray.cpp (.../TSubTaskArray.cpp) (revision 08717141ce5f6926116c298cbc9442094a45bb67) +++ src/libchengine/TSubTaskArray.cpp (.../TSubTaskArray.cpp) (revision 178e776294cbc8e3a5a33b355a314e0db94b214b) @@ -200,7 +200,6 @@ rSnapshot.Clear(); // current task - // ugly const_cast - const method, non-const interlocked intrinsic and we're really not modifying the member... object_id_t oidIndex = m_oidSubOperationIndex.load(std::memory_order_acquire); rSnapshot.SetCurrentSubtaskIndex(oidIndex); Index: src/libchengine/TSubTaskScanDirectory.cpp =================================================================== diff -u -r9fcf462ad4a28203a3d34ded6da7125d4dcc925c -r178e776294cbc8e3a5a33b355a314e0db94b214b --- src/libchengine/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision 9fcf462ad4a28203a3d34ded6da7125d4dcc925c) +++ src/libchengine/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision 178e776294cbc8e3a5a33b355a314e0db94b214b) @@ -209,7 +209,7 @@ m_tSubTaskStats.SetProcessedCount(totalCount); auto totalSize = rFilesCache.CalculateTotalSize(); m_tSubTaskStats.SetTotalSize(totalSize); - m_tSubTaskStats.SetProcessedSize(totalSize); + m_tSubTaskStats.SetProcessedSize(0); m_tSubTaskStats.SetCurrentPath(TString()); @@ -224,6 +224,7 @@ void TSubTaskScanDirectories::GetStatsSnapshot(TSubTaskStatsSnapshotPtr& spStats) const { m_tSubTaskStats.GetSnapshot(spStats); + spStats->SetIgnoreSizeInAggregateStats(true); } size_t TSubTaskScanDirectories::ScanDirectory(TSmartPath pathDirName, const TBasePathDataPtr& spBasePathData, @@ -278,10 +279,10 @@ auto totalCount = rFilesCache.GetCount(); m_tSubTaskStats.SetTotalCount(totalCount); - m_tSubTaskStats.SetProcessedCount(totalCount); + m_tSubTaskStats.SetProcessedCount(0); auto totalSize = rFilesCache.CalculateTotalSize(); m_tSubTaskStats.SetTotalSize(totalSize); - m_tSubTaskStats.SetProcessedSize(totalSize); + m_tSubTaskStats.SetProcessedSize(0); return stFilesCount; } Index: src/libchengine/TSubTaskStatsSnapshot.cpp =================================================================== diff -u -r9fcf462ad4a28203a3d34ded6da7125d4dcc925c -r178e776294cbc8e3a5a33b355a314e0db94b214b --- src/libchengine/TSubTaskStatsSnapshot.cpp (.../TSubTaskStatsSnapshot.cpp) (revision 9fcf462ad4a28203a3d34ded6da7125d4dcc925c) +++ src/libchengine/TSubTaskStatsSnapshot.cpp (.../TSubTaskStatsSnapshot.cpp) (revision 178e776294cbc8e3a5a33b355a314e0db94b214b) @@ -98,7 +98,9 @@ double TSubTaskStatsSnapshot::GetSizeSpeed() const { - return m_dAvgSizeSpeed; + if(m_bSubTaskIsRunning) + return m_dSizeSpeed; + return 0.0; } void TSubTaskStatsSnapshot::SetCountSpeed(double dCountSpeed) Index: src/libchengine/TSubTaskStatsSnapshot.h =================================================================== diff -u -r9fcf462ad4a28203a3d34ded6da7125d4dcc925c -r178e776294cbc8e3a5a33b355a314e0db94b214b --- src/libchengine/TSubTaskStatsSnapshot.h (.../TSubTaskStatsSnapshot.h) (revision 9fcf462ad4a28203a3d34ded6da7125d4dcc925c) +++ src/libchengine/TSubTaskStatsSnapshot.h (.../TSubTaskStatsSnapshot.h) (revision 178e776294cbc8e3a5a33b355a314e0db94b214b) @@ -55,6 +55,9 @@ void SetTotalSize(unsigned long long ullTotalSize) { m_ullTotalSize = ullTotalSize; } unsigned long long GetTotalSize() const { return m_ullTotalSize; } + bool GetIgnoreSizeInAggregateStats() const { return m_bIgnoreSizeInAggregateStats; } + void SetIgnoreSizeInAggregateStats(bool bIgnoreSizeInAggregateStats) { m_bIgnoreSizeInAggregateStats = bIgnoreSizeInAggregateStats; } + // current file void SetCurrentItemProcessedSize(unsigned long long ullProcessedSize) { m_ullCurrentItemProcessedSize = ullProcessedSize; } unsigned long long GetCurrentItemProcessedSize() const { return m_ullCurrentItemProcessedSize; } @@ -106,6 +109,9 @@ // subtask size and size speed per second unsigned long long m_ullTotalSize; unsigned long long m_ullProcessedSize; + + bool m_bIgnoreSizeInAggregateStats = false; + double m_dSizeSpeed = 0.0; double m_dAvgSizeSpeed = 0.0; Index: src/libchengine/TTaskManagerStatsSnapshot.cpp =================================================================== diff -u -r0d5b67ee96b435d63f7bf075dc8e28603793b187 -r178e776294cbc8e3a5a33b355a314e0db94b214b --- src/libchengine/TTaskManagerStatsSnapshot.cpp (.../TTaskManagerStatsSnapshot.cpp) (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187) +++ src/libchengine/TTaskManagerStatsSnapshot.cpp (.../TTaskManagerStatsSnapshot.cpp) (revision 178e776294cbc8e3a5a33b355a314e0db94b214b) @@ -109,28 +109,27 @@ for(TTaskStatsSnapshotPtr spTaskStats : m_vTasksSnapshots) { - m_ullProcessedCount += spTaskStats->GetProcessedCount(); - m_ullTotalCount += spTaskStats->GetTotalCount(); + if(spTaskStats->GetTaskState() == eTaskState_Waiting || + spTaskStats->GetTaskState() == eTaskState_Processing || + spTaskStats->GetTaskState() == eTaskState_Finished) + { + m_ullProcessedCount += spTaskStats->GetProcessedCount(); + m_ullTotalCount += spTaskStats->GetTotalCount(); - m_ullProcessedSize += spTaskStats->GetProcessedSize(); - m_ullTotalSize += spTaskStats->GetTotalSize(); + m_ullProcessedSize += spTaskStats->GetProcessedSize(); + m_ullTotalSize += spTaskStats->GetTotalSize(); - if(spTaskStats->IsTaskRunning()) - { - m_dCountSpeed += spTaskStats->GetCountSpeed(); - m_dSizeSpeed += spTaskStats->GetSizeSpeed(); - } + if(spTaskStats->IsTaskRunning()) + { + m_dCountSpeed += spTaskStats->GetCountSpeed(); + m_dSizeSpeed += spTaskStats->GetSizeSpeed(); + } - m_dAvgCountSpeed += spTaskStats->GetAvgCountSpeed(); - m_dAvgSizeSpeed += spTaskStats->GetAvgSizeSpeed(); + m_dAvgCountSpeed += spTaskStats->GetAvgCountSpeed(); + m_dAvgSizeSpeed += spTaskStats->GetAvgSizeSpeed(); + } } - if(!m_vTasksSnapshots.empty()) - { - m_dAvgCountSpeed /= m_vTasksSnapshots.size(); - m_dAvgSizeSpeed /= m_vTasksSnapshots.size(); - } - // we're treating each of the items as 4k object to process // to have some balance between items' count and items' size in // progress information Index: src/libchengine/TTaskStatsSnapshot.cpp =================================================================== diff -u -rc88853d744d42c9d0d18d14f920190d535bb714a -r178e776294cbc8e3a5a33b355a314e0db94b214b --- src/libchengine/TTaskStatsSnapshot.cpp (.../TTaskStatsSnapshot.cpp) (revision c88853d744d42c9d0d18d14f920190d535bb714a) +++ src/libchengine/TTaskStatsSnapshot.cpp (.../TTaskStatsSnapshot.cpp) (revision 178e776294cbc8e3a5a33b355a314e0db94b214b) @@ -82,7 +82,9 @@ m_ullProcessedSize = 0; m_ullTotalSize = 0; m_dTaskCountSpeed = 0.0; + m_dTaskAvgCountSpeed = 0.0; m_dTaskSizeSpeed = 0.0; + m_dTaskAvgSizeSpeed = 0.0; m_dCombinedProgress = 0.0; m_uiBufferCount = 0; } @@ -95,9 +97,13 @@ m_ullProcessedSize = 0; m_ullTotalSize = 0; m_dTaskCountSpeed = 0.0; + m_dTaskAvgCountSpeed = 0.0; m_dTaskSizeSpeed = 0.0; + m_dTaskAvgSizeSpeed = 0.0; m_dCombinedProgress = 0.0; + auto currentSubtask = m_tSubTasksStats.GetCurrentSubtaskIndex(); + size_t stCount = m_tSubTasksStats.GetSubTaskSnapshotCount(); for (size_t stIndex = 0; stIndex < stCount; ++stIndex) { @@ -106,13 +112,18 @@ m_ullProcessedCount += spSubtaskStats->GetProcessedCount(); m_ullTotalCount += spSubtaskStats->GetTotalCount(); - m_ullProcessedSize += spSubtaskStats->GetProcessedSize(); - m_ullTotalSize += spSubtaskStats->GetTotalSize(); + if(!spSubtaskStats->GetIgnoreSizeInAggregateStats()) + { + m_ullProcessedSize += spSubtaskStats->GetProcessedSize(); + m_ullTotalSize += spSubtaskStats->GetTotalSize(); + } - if(IsTaskRunning()) + if(stIndex == currentSubtask) { m_dTaskCountSpeed += spSubtaskStats->GetCountSpeed(); m_dTaskSizeSpeed += spSubtaskStats->GetSizeSpeed(); + m_dTaskAvgCountSpeed = spSubtaskStats->GetAvgCountSpeed(); + m_dTaskAvgSizeSpeed = spSubtaskStats->GetAvgSizeSpeed(); } } @@ -199,21 +210,15 @@ if (!m_bCacheFilled) CalculateProgressAndSpeeds(); - if (m_ullTimeElapsed) - return Math::Div64(m_ullProcessedCount, m_ullTimeElapsed / 1000.0); - - return 0.0; + return m_dTaskAvgCountSpeed; } double TTaskStatsSnapshot::GetAvgSizeSpeed() const { if (!m_bCacheFilled) CalculateProgressAndSpeeds(); - if (m_ullTimeElapsed) - return Math::Div64(m_ullProcessedSize, m_ullTimeElapsed / 1000.0); - - return 0.0; + return m_dTaskAvgSizeSpeed; } unsigned long long TTaskStatsSnapshot::GetEstimatedTotalTime() const Index: src/libchengine/TTaskStatsSnapshot.h =================================================================== diff -u -rc88853d744d42c9d0d18d14f920190d535bb714a -r178e776294cbc8e3a5a33b355a314e0db94b214b --- src/libchengine/TTaskStatsSnapshot.h (.../TTaskStatsSnapshot.h) (revision c88853d744d42c9d0d18d14f920190d535bb714a) +++ src/libchengine/TTaskStatsSnapshot.h (.../TTaskStatsSnapshot.h) (revision 178e776294cbc8e3a5a33b355a314e0db94b214b) @@ -148,8 +148,10 @@ mutable unsigned long long m_ullProcessedSize; mutable unsigned long long m_ullTotalSize; - mutable double m_dTaskCountSpeed; - mutable double m_dTaskSizeSpeed; + mutable double m_dTaskCountSpeed = 0.0; + mutable double m_dTaskAvgCountSpeed = 0.0; + mutable double m_dTaskSizeSpeed = 0.0; + mutable double m_dTaskAvgSizeSpeed = 0.0; mutable double m_dCombinedProgress; };