summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJosh Blum2013-07-13 14:24:49 -0700
committerJosh Blum2013-07-13 14:24:49 -0700
commit15dc0eaa715f41c3ebc05ce7b455e129218148a9 (patch)
tree8f9d939b65154fa2684c27f9201bffbda07720ef /lib
parentf0750ddbac8d7e334eac6a734af566bfedc98ed7 (diff)
downloadsandhi-15dc0eaa715f41c3ebc05ce7b455e129218148a9.tar.gz
sandhi-15dc0eaa715f41c3ebc05ce7b455e129218148a9.tar.bz2
sandhi-15dc0eaa715f41c3ebc05ce7b455e129218148a9.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/time_tag.cpp16
1 files 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 <boost/cstdint.hpp> //uint64
#include <boost/math/special_functions/round.hpp>
+#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<PMCTuple<2> >();
t._fsecs = tuple[0].as<boost::uint64_t>();
- t._ticks = boost::math::llround(tuple[1].as<double>()*time_tps());
+ t._ticks = boost::math::llround(tuple[1].as<double>()*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<boost::uint64_t>(_fsecs);
- tuple[1] = PMC_M<double>(_ticks/double(time_tps()));
+ tuple[1] = PMC_M<double>(_ticks/double(TIME_TAG_TPS));
return PMC_M(tuple);
}