mirror of
https://github.com/google/benchmark.git
synced 2025-03-06 23:30:14 +08:00
Merge branch 'upgrade-step2' into upgrade-step3
This commit is contained in:
commit
8f5cd9760f
@ -30,4 +30,4 @@ before_script:
|
|||||||
script:
|
script:
|
||||||
- cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_CXX_FLAGS="-std=${STD}"
|
- cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_CXX_FLAGS="-std=${STD}"
|
||||||
- make
|
- make
|
||||||
- make test
|
- make CTEST_OUTPUT_ON_FAILURE=1 test
|
||||||
|
@ -1179,6 +1179,9 @@ void RunSpecifiedBenchmarks(const BenchmarkReporter* reporter /*= nullptr*/) {
|
|||||||
void Initialize(int* argc, const char** argv) {
|
void Initialize(int* argc, const char** argv) {
|
||||||
internal::ParseCommandLineFlags(argc, argv);
|
internal::ParseCommandLineFlags(argc, argv);
|
||||||
internal::SetLogLevel(FLAGS_v);
|
internal::SetLogLevel(FLAGS_v);
|
||||||
|
// Ensure walltime is initialized by a single thread by forcing the
|
||||||
|
// initialization.
|
||||||
|
walltime::Now();
|
||||||
internal::Benchmark::MeasureOverhead();
|
internal::Benchmark::MeasureOverhead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,10 +15,12 @@
|
|||||||
#include "walltime.h"
|
#include "walltime.h"
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@ -31,7 +33,7 @@ namespace benchmark {
|
|||||||
namespace walltime {
|
namespace walltime {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
inline bool SplitTimezone(WallTime value, bool local, struct tm* t,
|
bool SplitTimezone(WallTime value, bool local, struct tm* t,
|
||||||
double* subsecond) {
|
double* subsecond) {
|
||||||
memset(t, 0, sizeof(*t));
|
memset(t, 0, sizeof(*t));
|
||||||
if ((value < 0) || (value > std::numeric_limits<time_t>::max())) {
|
if ((value < 0) || (value > std::numeric_limits<time_t>::max())) {
|
||||||
@ -50,7 +52,7 @@ inline bool SplitTimezone(WallTime value, bool local, struct tm* t,
|
|||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
|
|
||||||
namespace internal {
|
namespace {
|
||||||
|
|
||||||
class WallTimeImp
|
class WallTimeImp
|
||||||
{
|
{
|
||||||
@ -85,7 +87,7 @@ private:
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
WallTime Slow() {
|
WallTime Slow() const {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
return tv.tv_sec + tv.tv_usec * 1e-6;
|
return tv.tv_sec + tv.tv_usec * 1e-6;
|
||||||
@ -158,12 +160,12 @@ WallTimeImp::WallTimeImp()
|
|||||||
last_adjust_time_ = static_cast<uint32_t>(uint64_t(base_cycletime_) >> 32);
|
last_adjust_time_ = static_cast<uint32_t>(uint64_t(base_cycletime_) >> 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace internal
|
} // end anonymous namespace
|
||||||
|
|
||||||
|
|
||||||
WallTime Now()
|
WallTime Now()
|
||||||
{
|
{
|
||||||
static internal::WallTimeImp& imp = internal::WallTimeImp::GetWallTimeImp();
|
static WallTimeImp& imp = WallTimeImp::GetWallTimeImp();
|
||||||
return imp.Now();
|
return imp.Now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user