replace high_resolution_clock

This commit is contained in:
Nekotekina 2017-01-29 03:12:00 +03:00
parent a5a2d43d7c
commit be8d8ded3f
2 changed files with 9 additions and 9 deletions

View File

@ -6,8 +6,8 @@ class Timer
{
private:
bool m_stopped;
std::chrono::high_resolution_clock::time_point m_start;
std::chrono::high_resolution_clock::time_point m_end;
std::chrono::steady_clock::time_point m_start;
std::chrono::steady_clock::time_point m_end;
public:
Timer() : m_stopped(false)
@ -17,13 +17,13 @@ public:
void Start()
{
m_stopped = false;
m_start = std::chrono::high_resolution_clock::now();
m_start = std::chrono::steady_clock::now();
}
void Stop()
{
m_stopped = true;
m_end = std::chrono::high_resolution_clock::now();
m_end = std::chrono::steady_clock::now();
}
double GetElapsedTimeInSec() const
@ -38,14 +38,14 @@ public:
u64 GetElapsedTimeInMicroSec() const
{
std::chrono::high_resolution_clock::time_point now = m_stopped ? m_end : std::chrono::high_resolution_clock::now();
std::chrono::steady_clock::time_point now = m_stopped ? m_end : std::chrono::steady_clock::now();
return std::chrono::duration_cast<std::chrono::microseconds>(now - m_start).count();
}
u64 GetElapsedTimeInNanoSec() const
{
std::chrono::high_resolution_clock::time_point now = m_stopped ? m_end : std::chrono::high_resolution_clock::now();
std::chrono::steady_clock::time_point now = m_stopped ? m_end : std::chrono::steady_clock::now();
return std::chrono::duration_cast<std::chrono::nanoseconds>(now - m_start).count();
}

View File

@ -264,7 +264,7 @@ void LogFrame::OnTimer(wxTimerEvent& event)
return wxString::FromUTF8(buf.data(), size);
};
const auto start = std::chrono::high_resolution_clock::now();
const auto start = steady_clock::now();
// Check TTY logs
while (const u64 size = std::min<u64>(sizeof(buf), m_tty_file.size() - m_tty_file.pos()))
@ -274,7 +274,7 @@ void LogFrame::OnTimer(wxTimerEvent& event)
if (get_cfg_tty()) m_tty->AppendText(text);
// Limit processing time
if (std::chrono::high_resolution_clock::now() >= start + 4ms || text.empty()) break;
if (steady_clock::now() >= start + 4ms || text.empty()) break;
}
// Check main logs
@ -309,6 +309,6 @@ void LogFrame::OnTimer(wxTimerEvent& event)
s_gui_listener.pop();
// Limit processing time
if (std::chrono::high_resolution_clock::now() >= start + 7ms) break;
if (steady_clock::now() >= start + 7ms) break;
}
}