9 #include "imstkDataTracker.h" 14 DataTracker::DataTracker()
21 DataTracker::~DataTracker()
30 auto& e = getElement(name);
31 e.precision = precision;
32 e.notation = notation;
39 auto& e = getElement(index);
41 e.precision = precision;
42 e.notation = notation;
49 auto& e = getElement(name);
57 auto& e = getElement(index);
64 auto& e = getElement(index);
66 e.value = sw.getTimeElapsed();
70 DataTracker::getValue(
int idx)
72 return getElement(idx).value;
76 DataTracker::getValue(
const std::string& name)
78 return getElement(name).value;
82 DataTracker::getName(
int idx)
84 return getElement(idx).name;
88 DataTracker::getElement(std::string
const& name)
99 e.index = m_nextIndex++;
100 m_elements.push_back(e);
101 return m_elements.back();
105 DataTracker::getElement(
int idx)
117 m_elements.push_back(e);
118 return m_elements.back();
124 return m_timers[idx];
128 DataTracker::createFile()
130 if (m_file.is_open())
136 m_file.open(m_filename, std::ofstream::out | std::ofstream::trunc);
138 m_file <<
"Time(s)" << m_delimiter;
142 if ((++idx) < (m_elements.size()))
144 m_file << m_delimiter;
154 if (!m_file.is_open())
156 if (!m_filename.empty())
169 m_file << std::fixed << std::setprecision(3) << time << m_delimiter;
175 m_file << std::fixed << std::setprecision(0);
178 else if (d - ((
int)d) == 0)
180 m_file << std::fixed << std::setprecision(0);
183 else if (std::isnan(d))
191 case eDecimalFormat_Type::SystemFormatting:
192 m_file << std::fixed << std::setprecision(e.precision);
194 case eDecimalFormat_Type::DefaultFloat:
195 m_file << std::defaultfloat << std::setprecision(e.precision);
197 case eDecimalFormat_Type::FixedMantissa:
198 m_file << std::fixed << std::setprecision(e.precision);
200 case eDecimalFormat_Type::SignificantDigits:
201 m_file << std::scientific << std::setprecision(e.precision);
205 if ((++idx) < (m_elements.size()))
207 m_file << m_delimiter;
void streamProbesToFile(double time)
Write the current probe values to a row in the data file.
StopWatch & getStopWatch(int idx)
An available timer for each data item tracked.
Stop Watch utility class.
void probe(int idx, double value)
Track a data value associated with a header id.
int configureProbe(const std::string &name, std::streamsize precision=3, eDecimalFormat_Type notation=eDecimalFormat_Type::SystemFormatting)
Create and configure a probe and how it is written to file.
eDecimalFormat_Type
C++ I/O manipulation flags.
void probeElapsedTime_s(int idx)
Track a time duration associated with a header.