summaryrefslogtreecommitdiffstats
path: root/src/metrics.cc
diff options
context:
space:
mode:
authorBruce Dawson <brucedawson@chromium.org>2022-02-18 04:51:53 (GMT)
committerBruce Dawson <brucedawson@chromium.org>2022-02-18 04:51:53 (GMT)
commit65c82f4b99f29db594d6c65fee87f659d0cf94c0 (patch)
tree15bd5eb4d8e39c3033883f2aa9c6e5f684655a9c /src/metrics.cc
parent01e7c50f508b47409f2554285237722f010d0720 (diff)
downloadNinja-65c82f4b99f29db594d6c65fee87f659d0cf94c0.zip
Ninja-65c82f4b99f29db594d6c65fee87f659d0cf94c0.tar.gz
Ninja-65c82f4b99f29db594d6c65fee87f659d0cf94c0.tar.bz2
Cleanup
Diffstat (limited to 'src/metrics.cc')
-rw-r--r--src/metrics.cc30
1 files changed, 0 insertions, 30 deletions
diff --git a/src/metrics.cc b/src/metrics.cc
index 9b43883..9a4dd12 100644
--- a/src/metrics.cc
+++ b/src/metrics.cc
@@ -14,23 +14,12 @@
#include "metrics.h"
-#if __cplusplus >= 201103L
-// C++ 11 is not available on older Linux build machines.
-#define USE_CHRONO
-#endif
-
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
-
-#if defined(USE_CHRONO)
#include <chrono>
-#else
-#error
-#include <sys/time.h>
-#endif
#include "util.h"
@@ -42,20 +31,12 @@ namespace {
/// Compute a platform-specific high-res timer value that fits into an int64.
int64_t HighResTimer() {
-#if defined(USE_CHRONO)
auto now = chrono::steady_clock::now();
return chrono::duration_cast<chrono::steady_clock::duration>(
now.time_since_epoch())
.count();
-#else
- timeval tv;
- if (gettimeofday(&tv, NULL) < 0)
- Fatal("gettimeofday: %s", strerror(errno));
- return (int64_t)tv.tv_sec * 1000*1000 + tv.tv_usec;
-#endif
}
-#if defined(USE_CHRONO)
constexpr int64_t GetFrequency() {
// If numerator isn't 1 then we lose precision and that will need to be
// assessed.
@@ -64,26 +45,15 @@ constexpr int64_t GetFrequency() {
return std::chrono::steady_clock::period::den /
std::chrono::steady_clock::period::num;
}
-#endif
int64_t TimerToMicros(int64_t dt) {
-#if defined(USE_CHRONO)
// dt is in ticks. We want microseconds.
return (dt * 1000000) / GetFrequency();
-#else
- // No conversion necessary.
- return dt;
-#endif
}
int64_t TimerToMicros(double dt) {
-#if defined(USE_CHRONO)
// dt is in ticks. We want microseconds.
return (dt * 1000000) / GetFrequency();
-#else
- // No conversion necessary.
- return dt;
-#endif
}
} // anonymous namespace