diff --git a/client/app.C b/client/app.C index 251a4841f6..f1976a7687 100644 --- a/client/app.C +++ b/client/app.C @@ -1009,13 +1009,14 @@ int ACTIVE_TASK::get_cpu_time_via_shmem(time_t now) { recent_change = 0; } else { recent_change += (fraction_done - last_frac_done); - if ((now-last_frac_update)>0) { - recent_change = max(0, recent_change); + int tdiff = now-last_frac_update; + if (tdiff>0) { + double recent_frac_rate_of_change = max(0, recent_change) / tdiff; if (frac_rate_of_change == 0) { - frac_rate_of_change = recent_change; + frac_rate_of_change = recent_frac_rate_of_change; } else { - double x = exp(-(now-last_frac_update)*log(2.0)/20.0); - frac_rate_of_change = frac_rate_of_change*x + recent_change*(1-x); + double x = exp(-1*log(2.0)/20.0); + frac_rate_of_change = frac_rate_of_change*x + recent_frac_rate_of_change*(1-x); } last_frac_update = now; last_frac_done = fraction_done; @@ -1054,8 +1055,8 @@ double ACTIVE_TASK::est_time_to_completion() { if (fraction_done <= 0 || fraction_done > 1 || frac_rate_of_change <= 0) { return -1; } - return (1.0-fraction_done)/frac_rate_of_change; - //return (current_cpu_time / fraction_done) - current_cpu_time; + return (current_cpu_time / fraction_done) - current_cpu_time; + //return (1.0-fraction_done)/frac_rate_of_change; } // size of output files and files in slot dir diff --git a/client/win/wingui_mainwindow.cpp b/client/win/wingui_mainwindow.cpp index 84246f305b..055fc1fdde 100755 --- a/client/win/wingui_mainwindow.cpp +++ b/client/win/wingui_mainwindow.cpp @@ -384,16 +384,18 @@ void CMainWindow::UpdateGUI(CLIENT_STATE* pcs) // to completion double tocomp; - if(!at || at->fraction_done == 0) { + if(!at || (tocomp = at->est_time_to_completion()) <= 0) { tocomp = gstate.estimate_cpu_time(*re->wup); - } else { - tocomp = at->est_time_to_completion(); } if (tocomp > 0) { cpuhour = (int)(tocomp / (60 * 60)); cpumin = (int)(tocomp / 60) % 60; cpusec = (int)(tocomp) % 60; strBuf.Format("%0.2d:%0.2d:%0.2d", cpuhour, cpumin, cpusec); + //strBuf.Format("%s [%.f]", strBuf, tocomp); + //if (at) { + // strBuf.Format("%s frac_done=%.7f frac_r=%.9f rec_ch=%.9f", strBuf, at->fraction_done, at->frac_rate_of_change, at->recent_change); + //} } else { strBuf = "---"; }