[PATCH] D46937: [Timers] TimerGroup::printJSONValue(): print doubles with no precision loss
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 16 11:20:00 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332504: [Timers] TimerGroup::printJSONValue(): print doubles with no precision loss (authored by lebedevri, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D46937?vs=147053&id=147138#toc
Repository:
rL LLVM
https://reviews.llvm.org/D46937
Files:
llvm/trunk/lib/Support/Timer.cpp
Index: llvm/trunk/lib/Support/Timer.cpp
===================================================================
--- llvm/trunk/lib/Support/Timer.cpp
+++ llvm/trunk/lib/Support/Timer.cpp
@@ -22,6 +22,8 @@
#include "llvm/Support/Process.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"
+#include <limits>
+
using namespace llvm;
// This ugly hack is brought to you courtesy of constructor/destructor ordering
@@ -367,10 +369,12 @@
void TimerGroup::printJSONValue(raw_ostream &OS, const PrintRecord &R,
const char *suffix, double Value) {
assert(yaml::needsQuotes(Name) == yaml::QuotingType::None &&
- "TimerGroup name needs no quotes");
+ "TimerGroup name should not need quotes");
assert(yaml::needsQuotes(R.Name) == yaml::QuotingType::None &&
- "Timer name needs no quotes");
- OS << "\t\"time." << Name << '.' << R.Name << suffix << "\": " << Value;
+ "Timer name should not need quotes");
+ constexpr auto max_digits10 = std::numeric_limits<double>::max_digits10;
+ OS << "\t\"time." << Name << '.' << R.Name << suffix
+ << "\": " << format("%.*e", max_digits10 - 1, Value);
}
const char *TimerGroup::printJSONValues(raw_ostream &OS, const char *delim) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46937.147138.patch
Type: text/x-patch
Size: 1272 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180516/e0257c58/attachment.bin>
More information about the cfe-commits
mailing list