mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Increased int size for timers to avoid truncations
This commit is contained in:
parent
c4d1aa9033
commit
4da655c1b0
@ -9,6 +9,7 @@
|
|||||||
#include "catch_timer.h"
|
#include "catch_timer.h"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
@ -45,11 +46,11 @@ namespace Catch {
|
|||||||
void Timer::start() {
|
void Timer::start() {
|
||||||
m_nanoseconds = getCurrentNanosecondsSinceEpoch();
|
m_nanoseconds = getCurrentNanosecondsSinceEpoch();
|
||||||
}
|
}
|
||||||
auto Timer::getElapsedNanoseconds() const -> unsigned int {
|
auto Timer::getElapsedNanoseconds() const -> uint64_t {
|
||||||
return static_cast<unsigned int>(getCurrentNanosecondsSinceEpoch() - m_nanoseconds);
|
return getCurrentNanosecondsSinceEpoch() - m_nanoseconds;
|
||||||
}
|
}
|
||||||
auto Timer::getElapsedMicroseconds() const -> unsigned int {
|
auto Timer::getElapsedMicroseconds() const -> uint64_t {
|
||||||
return static_cast<unsigned int>(getElapsedNanoseconds()/1000);
|
return getElapsedNanoseconds()/1000;
|
||||||
}
|
}
|
||||||
auto Timer::getElapsedMilliseconds() const -> unsigned int {
|
auto Timer::getElapsedMilliseconds() const -> unsigned int {
|
||||||
return static_cast<unsigned int>(getElapsedMicroseconds()/1000);
|
return static_cast<unsigned int>(getElapsedMicroseconds()/1000);
|
||||||
|
@ -19,8 +19,8 @@ namespace Catch {
|
|||||||
uint64_t m_nanoseconds = 0;
|
uint64_t m_nanoseconds = 0;
|
||||||
public:
|
public:
|
||||||
void start();
|
void start();
|
||||||
auto getElapsedNanoseconds() const -> unsigned int;
|
auto getElapsedNanoseconds() const -> uint64_t;
|
||||||
auto getElapsedMicroseconds() const -> unsigned int;
|
auto getElapsedMicroseconds() const -> uint64_t;
|
||||||
auto getElapsedMilliseconds() const -> unsigned int;
|
auto getElapsedMilliseconds() const -> unsigned int;
|
||||||
auto getElapsedSeconds() const -> double;
|
auto getElapsedSeconds() const -> double;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user