}
}/* TimerStat::stop() */
+timespec TimerStat::getData() const {
+ ::timespec data = d_data;
+ if(__CVC4_USE_STATISTICS && d_running) {
+ ::timespec end;
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ data += end - d_start;
+ }
+ return data;
+}
+
+SExpr TimerStat::getValue() const {
+ ::timespec data = d_data;
+ if(__CVC4_USE_STATISTICS && d_running) {
+ ::timespec end;
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ data += end - d_start;
+ }
+ std::stringstream ss;
+ ss << std::fixed << std::setprecision(8) << data;
+ return SExpr(Rational::fromDecimal(ss.str()));
+}/* TimerStat::getValue() */
+
RegisterStatistic::RegisterStatistic(ExprManager& em, Stat* stat) :
d_reg(stats::getStatisticsRegistry(&em)),
d_stat(stat) {
}
/** Get the value of the statistic. */
- virtual const T& getData() const = 0;
+ virtual T getData() const = 0;
/** Flush the value of the statistic to the given output stream. */
void flushInformation(std::ostream& out) const {
}
/** Get the value of the referenced data cell. */
- const T& getData() const {
+ T getData() const {
return *d_data;
}
}
/** Get the underlying data value. */
- const T& getData() const {
+ T getData() const {
return d_data;
}
}
/** Get the data of the underlying (wrapped) statistic. */
- const T& getData() const {
+ T getData() const {
return d_stat.getData();
}
*/
void stop();
- SExpr getValue() const {
- std::stringstream ss;
- ss << std::fixed << std::setprecision(8) << d_data;
- return SExpr(Rational::fromDecimal(ss.str()));
- }
+ timespec getData() const;
+
+ SExpr getValue() const;
};/* class TimerStat */
sTimer.start();
timespec zero = { 0, 0 };
- TS_ASSERT_EQUALS(zero, sTimer.getData());
+ //TS_ASSERT_EQUALS(zero, sTimer.getData());
sTimer.stop();
TS_ASSERT_LESS_THAN(zero, sTimer.getData());
#endif /* CVC4_STATISTICS_ON */