mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Don't cast nanoseconds to integers when writing output
This commit is contained in:
parent
c4e5b05cfc
commit
efbfaa1704
@ -211,15 +211,11 @@ class Duration {
|
|||||||
static const uint64_t s_nanosecondsInASecond = 1000 * s_nanosecondsInAMillisecond;
|
static const uint64_t s_nanosecondsInASecond = 1000 * s_nanosecondsInAMillisecond;
|
||||||
static const uint64_t s_nanosecondsInAMinute = 60 * s_nanosecondsInASecond;
|
static const uint64_t s_nanosecondsInAMinute = 60 * s_nanosecondsInASecond;
|
||||||
|
|
||||||
uint64_t m_inNanoseconds;
|
double m_inNanoseconds;
|
||||||
Unit m_units;
|
Unit m_units;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Duration(double inNanoseconds, Unit units = Unit::Auto)
|
explicit Duration(double inNanoseconds, Unit units = Unit::Auto)
|
||||||
: Duration(static_cast<uint64_t>(inNanoseconds), units) {
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit Duration(uint64_t inNanoseconds, Unit units = Unit::Auto)
|
|
||||||
: m_inNanoseconds(inNanoseconds),
|
: m_inNanoseconds(inNanoseconds),
|
||||||
m_units(units) {
|
m_units(units) {
|
||||||
if (m_units == Unit::Auto) {
|
if (m_units == Unit::Auto) {
|
||||||
@ -248,7 +244,7 @@ public:
|
|||||||
case Unit::Minutes:
|
case Unit::Minutes:
|
||||||
return m_inNanoseconds / static_cast<double>(s_nanosecondsInAMinute);
|
return m_inNanoseconds / static_cast<double>(s_nanosecondsInAMinute);
|
||||||
default:
|
default:
|
||||||
return static_cast<double>(m_inNanoseconds);
|
return m_inNanoseconds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringRef unitsAsString() const {
|
StringRef unitsAsString() const {
|
||||||
|
@ -229,16 +229,16 @@ namespace Catch {
|
|||||||
m_xml.writeAttribute("samples", info.samples)
|
m_xml.writeAttribute("samples", info.samples)
|
||||||
.writeAttribute("resamples", info.resamples)
|
.writeAttribute("resamples", info.resamples)
|
||||||
.writeAttribute("iterations", info.iterations)
|
.writeAttribute("iterations", info.iterations)
|
||||||
.writeAttribute("clockResolution", static_cast<uint64_t>(info.clockResolution))
|
.writeAttribute("clockResolution", info.clockResolution)
|
||||||
.writeAttribute("estimatedDuration", static_cast<uint64_t>(info.estimatedDuration))
|
.writeAttribute("estimatedDuration", info.estimatedDuration)
|
||||||
.writeComment("All values in nano seconds");
|
.writeComment("All values in nano seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlReporter::benchmarkEnded(BenchmarkStats<> const& benchmarkStats) {
|
void XmlReporter::benchmarkEnded(BenchmarkStats<> const& benchmarkStats) {
|
||||||
m_xml.startElement("mean")
|
m_xml.startElement("mean")
|
||||||
.writeAttribute("value", static_cast<uint64_t>(benchmarkStats.mean.point.count()))
|
.writeAttribute("value", benchmarkStats.mean.point.count())
|
||||||
.writeAttribute("lowerBound", static_cast<uint64_t>(benchmarkStats.mean.lower_bound.count()))
|
.writeAttribute("lowerBound", benchmarkStats.mean.lower_bound.count())
|
||||||
.writeAttribute("upperBound", static_cast<uint64_t>(benchmarkStats.mean.upper_bound.count()))
|
.writeAttribute("upperBound", benchmarkStats.mean.upper_bound.count())
|
||||||
.writeAttribute("ci", benchmarkStats.mean.confidence_interval);
|
.writeAttribute("ci", benchmarkStats.mean.confidence_interval);
|
||||||
m_xml.endElement();
|
m_xml.endElement();
|
||||||
m_xml.startElement("standardDeviation")
|
m_xml.startElement("standardDeviation")
|
||||||
|
Loading…
Reference in New Issue
Block a user