From 15dc0eaa715f41c3ebc05ce7b455e129218148a9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 13 Jul 2013 14:24:49 -0700 Subject: gras: always use ns for TimeTag The msvc performance counter tps isnt very high. And as it turns out, we dont need to care, since its all internal to the implementation. --- lib/time_tag.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/time_tag.cpp b/lib/time_tag.cpp index b2beadf..b80e944 100644 --- a/lib/time_tag.cpp +++ b/lib/time_tag.cpp @@ -5,14 +5,16 @@ #include //uint64 #include +#define TIME_TAG_TPS time_ticks_t(1000000000UL) + using namespace gras; static TimeTag &normalize(TimeTag &t) { - int num = int(t._ticks/time_tps()); + int num = int(t._ticks/TIME_TAG_TPS); if (num < 0) num--; //stops negative ticks t._fsecs += num; - t._ticks -= num*time_tps(); + t._ticks -= num*TIME_TAG_TPS; return t; } @@ -32,7 +34,7 @@ TimeTag TimeTag::from_ticks(const time_ticks_t ticks, const double rate) TimeTag t; t._fsecs = time_ticks_t(ticks/rate); const double error = ticks - (t._fsecs*rate); - t._ticks = boost::math::llround((error*time_tps())/rate); + t._ticks = boost::math::llround((error*TIME_TAG_TPS)/rate); return normalize(t); } @@ -41,27 +43,27 @@ TimeTag TimeTag::from_pmc(const PMCC &p) TimeTag t; const PMCTuple<2> &tuple = p.as >(); t._fsecs = tuple[0].as(); - t._ticks = boost::math::llround(tuple[1].as()*time_tps()); + t._ticks = boost::math::llround(tuple[1].as()*TIME_TAG_TPS); return normalize(t); } time_ticks_t TimeTag::to_ticks(void) const { - return _fsecs*time_tps() + _ticks; + return _fsecs*TIME_TAG_TPS + _ticks; } time_ticks_t TimeTag::to_ticks(const double rate) const { const time_ticks_t full = time_ticks_t(_fsecs*rate); const double error = _fsecs - (full/rate); - return full + boost::math::llround(_ticks*rate/time_tps() + error*rate); + return full + boost::math::llround(_ticks*rate/TIME_TAG_TPS + error*rate); } PMCC TimeTag::to_pmc(void) const { PMCTuple<2> tuple; tuple[0] = PMC_M(_fsecs); - tuple[1] = PMC_M(_ticks/double(time_tps())); + tuple[1] = PMC_M(_ticks/double(TIME_TAG_TPS)); return PMC_M(tuple); } -- cgit