mirror of
https://github.com/saymrwulf/uhd.git
synced 2026-05-16 21:10:10 +00:00
uhd::get_system_time() is currently only used in USRP1 code, and it turns out that our "optimized", platform-dependent implementation still is a little slower than straight-up chrono. We therefore remove all the special cases, and replace them with a single, standard solution.
16 lines
538 B
C++
16 lines
538 B
C++
//
|
|
// Copyright 2017 Ettus Research (National Instruments Corp.)
|
|
//
|
|
// SPDX-License-Identifier: GPL-3.0+
|
|
//
|
|
|
|
#include <uhdlib/utils/system_time.hpp>
|
|
#include <chrono>
|
|
|
|
uhd::time_spec_t uhd::get_system_time(void)
|
|
{
|
|
const auto now = std::chrono::steady_clock::now().time_since_epoch();
|
|
const auto seconds = std::chrono::duration_cast<std::chrono::seconds>(now);
|
|
const auto nanoseconds = std::chrono::duration_cast<std::chrono::nanoseconds>(now-seconds);
|
|
return uhd::time_spec_t(seconds.count(), nanoseconds.count(), 1e9);
|
|
}
|