mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-25 14:05:39 +02:00
Started work on splitting out .cpp files from header files
This commit is contained in:
34
include/internal/catch_timer.cpp
Normal file
34
include/internal/catch_timer.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Created by Phil on 05/08/2013.
|
||||
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#include "catch_timer.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
namespace {
|
||||
uint64_t getCurrentMicrosecondsSinceEpoch() {
|
||||
return std::chrono::duration_cast<std::chrono::microseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
|
||||
}
|
||||
}
|
||||
|
||||
void Timer::start() {
|
||||
m_microSeconds = getCurrentMicrosecondsSinceEpoch();
|
||||
}
|
||||
unsigned int Timer::getElapsedMicroseconds() const {
|
||||
return static_cast<unsigned int>(getCurrentMicrosecondsSinceEpoch() - m_microSeconds);
|
||||
}
|
||||
unsigned int Timer::getElapsedMilliseconds() const {
|
||||
return static_cast<unsigned int>(getElapsedMicroseconds()/1000);
|
||||
}
|
||||
double Timer::getElapsedSeconds() const {
|
||||
return getElapsedMicroseconds()/1000000.0;
|
||||
}
|
||||
|
||||
} // namespace Catch
|
Reference in New Issue
Block a user