mirror of
https://github.com/mhx/dwarfs.git
synced 2025-08-04 10:16:34 -04:00
clang-format speedometer
This commit is contained in:
parent
67f340e383
commit
2848ab3a75
@ -29,7 +29,8 @@ namespace dwarfs {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
class speedometer {
|
class speedometer {
|
||||||
public:
|
public:
|
||||||
speedometer(std::chrono::milliseconds window_length) : window_length_{window_length} {}
|
speedometer(std::chrono::milliseconds window_length)
|
||||||
|
: window_length_{window_length} {}
|
||||||
|
|
||||||
void put(T s) {
|
void put(T s) {
|
||||||
auto now = std::chrono::steady_clock::now();
|
auto now = std::chrono::steady_clock::now();
|
||||||
@ -50,12 +51,11 @@ class speedometer {
|
|||||||
auto const& last = samples_.back();
|
auto const& last = samples_.back();
|
||||||
auto dt = last.first - first.first;
|
auto dt = last.first - first.first;
|
||||||
auto dv = last.second - first.second;
|
auto dv = last.second - first.second;
|
||||||
return (1000 * dv) / std::chrono::duration_cast<std::chrono::milliseconds>(dt).count();
|
return (1000 * dv) /
|
||||||
|
std::chrono::duration_cast<std::chrono::milliseconds>(dt).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() { samples_.clear(); }
|
||||||
samples_.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::deque<std::pair<std::chrono::steady_clock::time_point, T>> samples_;
|
std::deque<std::pair<std::chrono::steady_clock::time_point, T>> samples_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user