Skip to content
This repository has been archived by the owner on Dec 7, 2024. It is now read-only.

Commit

Permalink
Time elapsed is no longer broken
Browse files Browse the repository at this point in the history
oopsie
  • Loading branch information
WorkingRobot committed Apr 15, 2020
1 parent 53f081b commit 262ad31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions gui/cProgress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ cProgress::cProgress(cMain* main, wxString taskName, cancel_flag& cancelFlag, fl
value = 0;
frequency = updateFreq;
maxValue = maximum;
etaTimePoints.push(std::make_pair(0, Clock::now()));
startTime = Clock::now();
etaTimePoints.push(std::make_pair(0, startTime));

this->SetIcon(wxICON(APP_ICON));
this->SetMinSize(wxSize(400, -1));
Expand Down Expand Up @@ -87,10 +88,11 @@ inline void cProgress::Update(bool force) {
progressPercent->SetLabel(wxString::Format("%.2f%%", float(value) * 100 / maxValue));
progressTotal->SetLabel(wxString::Format("%u / %u", value.load(), maxValue));

auto& timePoint = etaTimePoints.front();
auto elapsed = ch::duration_cast<ch::seconds>(now - timePoint.second);
auto elapsed = ch::duration_cast<ch::seconds>(now - startTime);
progressTimeElapsed->SetLabel("Elapsed: " + FormatTime(elapsed));

auto& timePoint = etaTimePoints.front();
auto etaElapsed = ch::duration_cast<ch::seconds>(now - timePoint.second);
auto etaCount = value - timePoint.first;
auto etaDivisor = float(maxValue - etaCount) / etaCount;
auto eta = etaDivisor ? ch::duration_cast<ch::seconds>(elapsed * etaDivisor) : ch::seconds::zero();
Expand Down
1 change: 1 addition & 0 deletions gui/cProgress.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class cProgress : public wxFrame

bool finished = false;
std::queue<std::pair<uint32_t, Clock::time_point>> etaTimePoints;
Clock::time_point startTime;
Clock::time_point lastUpdate;
float frequency;
std::atomic_uint32_t value;
Expand Down

0 comments on commit 262ad31

Please sign in to comment.