diff options
4 files changed, 11 insertions, 12 deletions
diff --git a/searchlib/src/vespa/searchlib/engine/trace.cpp b/searchlib/src/vespa/searchlib/engine/trace.cpp index d2942f2be6b..2264685ca13 100644 --- a/searchlib/src/vespa/searchlib/engine/trace.cpp +++ b/searchlib/src/vespa/searchlib/engine/trace.cpp @@ -41,7 +41,7 @@ Trace::start(int level, bool useUTC) { if (useUTC) { root().setString("start_time", vespalib::to_string(vespalib::to_utc(_relativeTime.timeOfDawn()))); } else { - root().setString("start_time", vespalib::to_string(_relativeTime.timeOfDawn())); + root().setString("start_time", vespalib::to_string(vespalib::system_time(_relativeTime.timeOfDawn().time_since_epoch()))); } } } diff --git a/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.cpp b/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.cpp index b88133c0bf9..e6133496398 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.cpp @@ -35,7 +35,7 @@ struct DomainExplorer : vespalib::StateExplorer { { FastOS_StatInfo stat_info; FastOS_File::Stat(part_in.file.c_str(), &stat_info); - part.setString("lastModified", vespalib::to_string(std::chrono::nanoseconds(stat_info._modifiedTimeNS))); + part.setString("lastModified", vespalib::to_string(vespalib::system_time(std::chrono::nanoseconds(stat_info._modifiedTimeNS)))); } } } diff --git a/vespalib/src/vespa/vespalib/util/time.cpp b/vespalib/src/vespa/vespalib/util/time.cpp index fd5d3e3055e..15dc8b4c781 100644 --- a/vespalib/src/vespa/vespalib/util/time.cpp +++ b/vespalib/src/vespa/vespalib/util/time.cpp @@ -2,6 +2,7 @@ #include "time.h" #include <thread> +#include <immintrin.h> namespace vespalib { @@ -12,27 +13,25 @@ to_utc(steady_time ts) { return system_time(nowUtc.time_since_epoch() - nowSteady.time_since_epoch() + ts.time_since_epoch()); } +namespace { + string -to_string(duration dur) -{ +to_string(duration dur) { time_t timeStamp = std::chrono::duration_cast<std::chrono::seconds>(dur).count(); struct tm timeStruct; gmtime_r(&timeStamp, &timeStruct); char timeString[128]; strftime(timeString, sizeof(timeString), "%F %T", &timeStruct); char retval[160]; - uint32_t milliSeconds = count_ms(dur)%1000; + uint32_t milliSeconds = count_ms(dur) % 1000; snprintf(retval, sizeof(retval), "%s.%03u UTC", timeString, milliSeconds); return std::string(retval); } -string -to_string(system_time time) { - return to_string(time.time_since_epoch()); } string -to_string(steady_time time) { +to_string(system_time time) { return to_string(time.time_since_epoch()); } @@ -43,7 +42,9 @@ Timer::waitAtLeast(duration dur, bool busyWait) { if (busyWait) { steady_clock::time_point deadline = steady_clock::now() + dur; while (steady_clock::now() < deadline) { - for (int i = 0; i < 1000; i++) { } + for (int i = 0; i < 1000; i++) { + _mm_pause(); + } } } else { std::this_thread::sleep_for(dur); diff --git a/vespalib/src/vespa/vespalib/util/time.h b/vespalib/src/vespa/vespalib/util/time.h index 187d62001ae..d57d722efc4 100644 --- a/vespalib/src/vespa/vespalib/util/time.h +++ b/vespalib/src/vespa/vespalib/util/time.h @@ -67,8 +67,6 @@ constexpr duration from_timeval(const timeval & tv) { } vespalib::string to_string(system_time time); -vespalib::string to_string(steady_time time); -vespalib::string to_string(duration time); /** * Simple utility class used to measure how much time has elapsed |