本文整理汇总了C++中time_duration::total_microseconds方法的典型用法代码示例。如果您正苦于以下问题:C++ time_duration::total_microseconds方法的具体用法?C++ time_duration::total_microseconds怎么用?C++ time_duration::total_microseconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类time_duration
的用法示例。
在下文中一共展示了time_duration::total_microseconds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: max
Typesystem::Int64 MonotonicClock::Get(const Typesystem::Int64 oldTime)
{
using namespace boost::posix_time;
const ptime now = microsec_clock::universal_time();
const time_duration diff = now - epoch;
const Typesystem::Int64 newTime = diff.total_microseconds();
return std::max(newTime,oldTime+1);
}
示例2: secondsFromDuration
/**
* Return the number of seconds in a time_duration, as a double, including
* fractional seconds.
*/
double DateAndTime::secondsFromDuration(time_duration duration) {
#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
// Nanosecond resolution
return static_cast<double>(duration.total_nanoseconds()) / 1e9;
#else
// Microsecond resolution
return static_cast<double>(duration.total_microseconds()) / 1e6;
#endif
}
示例3: epoch
RandomGenerator()
{
using namespace boost::posix_time;
const ptime epoch(boost::gregorian::date(2008,1,1));
const ptime now = microsec_clock::universal_time();
const time_duration diff = now - epoch;
const boost::uint32_t my_seed =
(static_cast<boost::uint32_t>(diff.total_microseconds()) * Safir::Utilities::ProcessInfo::GetPid())
% std::numeric_limits<boost::uint32_t>::max();
m_randomGenerator.seed(my_seed);
}
示例4: microseconds
TSVolatility::TSVolatility( Prices& series, time_duration dtTau, time_duration dtTauPrime, double p, unsigned int n )
: m_seriesSource( series ),
m_dtTau( dtTau ),
m_dtTauByTwo( microseconds( dtTau.total_microseconds() / 2 ) ),
// m_dtTauPrime( microseconds( dtTauPrime.total_microseconds() / 2 ) ),
m_dtTauPrime( dtTauPrime ),
m_p( p ),
m_n( n ),
m_tsDif( series, dtTauPrime ),
m_tsNorm( m_tsDif, m_dtTauByTwo, n, p )
{
}
示例5: nanosecondsFromDuration
/** time duration in nanoseconds. Duration is limited to
* MAX_NANOSECONDS and MIN_NANOSECONDS to avoid overflows.
* @param td :: time_duration instance.
* @return an int64 of the number of nanoseconds
*/
int64_t DateAndTime::nanosecondsFromDuration(const time_duration &td) {
int64_t nano;
#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
// Nanosecond resolution
nano = td.total_nanoseconds();
#else
// Microsecond resolution
nano = (td.total_microseconds() * 1000);
#endif
// Use these limits to avoid integer overflows
if (nano > MAX_NANOSECONDS)
return MAX_NANOSECONDS;
else if (nano < MIN_NANOSECONDS)
return MIN_NANOSECONDS;
else
return nano;
}