File tree 1 file changed +10
-3
lines changed 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -1123,17 +1123,24 @@ std::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {
1123
1123
// A helper class for measuring elapsed times.
1124
1124
class Timer {
1125
1125
public:
1126
- Timer () : start_(std::chrono::steady_clock ::now()) {}
1126
+ Timer () : start_(clock ::now()) {}
1127
1127
1128
1128
// Return time elapsed in milliseconds since the timer was created.
1129
1129
TimeInMillis Elapsed () {
1130
1130
return std::chrono::duration_cast<std::chrono::milliseconds>(
1131
- std::chrono::steady_clock ::now () - start_)
1131
+ clock ::now () - start_)
1132
1132
.count ();
1133
1133
}
1134
1134
1135
1135
private:
1136
- std::chrono::steady_clock::time_point start_;
1136
+ // Fall back to the system_clock when building with newlib on a system
1137
+ // without a monotonic clock.
1138
+ #if defined(_NEWLIB_VERSION) && !defined(CLOCK_MONOTONIC)
1139
+ using clock = std::chrono::system_clock;
1140
+ #else
1141
+ using clock = std::chrono::steady_clock;
1142
+ #endif
1143
+ clock::time_point start_;
1137
1144
};
1138
1145
1139
1146
// Returns a timestamp as milliseconds since the epoch. Note this time may jump
You can’t perform that action at this time.
0 commit comments