mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Moved Timer impl back to cpp
(I thought it wasn't included on the non-main path, but it is)
This commit is contained in:
parent
39d37d9f34
commit
a1e3f0b624
@ -16,4 +16,21 @@ namespace Catch {
|
|||||||
return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
|
return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Timer::start() {
|
||||||
|
m_nanoseconds = getCurrentNanosecondsSinceEpoch();
|
||||||
|
}
|
||||||
|
auto Timer::getElapsedNanoseconds() const -> unsigned int {
|
||||||
|
return static_cast<unsigned int>(getCurrentNanosecondsSinceEpoch() - m_nanoseconds);
|
||||||
|
}
|
||||||
|
auto Timer::getElapsedMicroseconds() const -> unsigned int {
|
||||||
|
return static_cast<unsigned int>(getElapsedNanoseconds()/1000);
|
||||||
|
}
|
||||||
|
auto Timer::getElapsedMilliseconds() const -> unsigned int {
|
||||||
|
return static_cast<unsigned int>(getElapsedMicroseconds()/1000);
|
||||||
|
}
|
||||||
|
auto Timer::getElapsedSeconds() const -> double {
|
||||||
|
return getElapsedMicroseconds()/1000000.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
@ -17,21 +17,11 @@ namespace Catch {
|
|||||||
class Timer {
|
class Timer {
|
||||||
uint64_t m_nanoseconds = 0;
|
uint64_t m_nanoseconds = 0;
|
||||||
public:
|
public:
|
||||||
void start() {
|
void start();
|
||||||
m_nanoseconds = getCurrentNanosecondsSinceEpoch();
|
auto getElapsedNanoseconds() const -> unsigned int;
|
||||||
}
|
auto getElapsedMicroseconds() const -> unsigned int;
|
||||||
auto getElapsedNanoseconds() const -> unsigned int {
|
auto getElapsedMilliseconds() const -> unsigned int;
|
||||||
return static_cast<unsigned int>(getCurrentNanosecondsSinceEpoch() - m_nanoseconds);
|
auto getElapsedSeconds() const -> double;
|
||||||
}
|
|
||||||
auto getElapsedMicroseconds() const -> unsigned int {
|
|
||||||
return static_cast<unsigned int>(getElapsedNanoseconds()/1000);
|
|
||||||
}
|
|
||||||
auto getElapsedMilliseconds() const -> unsigned int {
|
|
||||||
return static_cast<unsigned int>(getElapsedMicroseconds()/1000);
|
|
||||||
}
|
|
||||||
auto getElapsedSeconds() const -> double {
|
|
||||||
return getElapsedMicroseconds()/1000000.0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
Loading…
Reference in New Issue
Block a user