double GuideAlgorithmLowpass::result(double input) { m_history.Add(input); ArrayOfDbl sortedHistory(m_history); sortedHistory.Sort(dbl_sort_func); m_history.RemoveAt(0); unsigned int numpts = m_history.GetCount(); double median = sortedHistory[sortedHistory.GetCount()/2]; double slope = CalcSlope(m_history); double dReturn = median + m_slopeWeight*slope; if (fabs(dReturn) > fabs(input)) { Debug.Write(wxString::Format("GuideAlgorithmLowpass::Result() input %.2f is < calculated value %.2f, using input\n", input, dReturn)); dReturn = input; } //TODO: Undertand this. I think this is wrong, since it divides the orignial input // by 11 if it was less than the computed value. And since the computed // value is median + slope, I'm not sure that it should be divided by 11 // either. But the goal of this exercise is to be bug for bug compatible // with PHD 1.x if (fabs(input) < m_minMove) { dReturn = 0.0; } Debug.Write(wxString::Format("GuideAlgorithmLowpass::Result() returns %.2f from input %.2f\n", dReturn, input)); return dReturn; }
double ThrottledTextureUploader::estimatedTexturesPerSecond() { processQueries(); // The history should never be empty because we initialize all elements with an estimate. ASSERT(m_texturesPerSecondHistory.size() == uploadHistorySize); // Sort the history and use the median as our estimate. std::vector<double> sortedHistory(m_texturesPerSecondHistory.begin(), m_texturesPerSecondHistory.end()); std::sort(sortedHistory.begin(), sortedHistory.end()); estimatedTexturesPerSecondGlobal = sortedHistory[sortedHistory.size() * 2 / 3]; TRACE_COUNTER1("cc", "estimatedTexturesPerSecond", estimatedTexturesPerSecondGlobal); return estimatedTexturesPerSecondGlobal; }