summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2016-11-18 19:43:24 +0000
committerMatthias Braun <matze@braunis.de>2016-11-18 19:43:24 +0000
commitdb39fd6c53f8ea68bea29d99001336de95a72cdc (patch)
treeb094e2e9e0d1f80ded6eb9358b97eae3f1212a12 /llvm/include
parent9f15a79e5d89a814480eb2e0e53ff0e13d56fc8f (diff)
downloadbcm5719-llvm-db39fd6c53f8ea68bea29d99001336de95a72cdc.tar.gz
bcm5719-llvm-db39fd6c53f8ea68bea29d99001336de95a72cdc.zip
Statistic/Timer: Include timers in PrintStatisticsJSON().
Differential Revision: https://reviews.llvm.org/D25588 llvm-svn: 287370
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/ADT/Statistic.h5
-rw-r--r--llvm/include/llvm/Support/Timer.h26
2 files changed, 29 insertions, 2 deletions
diff --git a/llvm/include/llvm/ADT/Statistic.h b/llvm/include/llvm/ADT/Statistic.h
index 0f797ec8de2..53fa2a50fcb 100644
--- a/llvm/include/llvm/ADT/Statistic.h
+++ b/llvm/include/llvm/ADT/Statistic.h
@@ -165,7 +165,10 @@ void PrintStatistics();
/// \brief Print statistics to the given output stream.
void PrintStatistics(raw_ostream &OS);
-/// Print statistics in JSON format.
+/// Print statistics in JSON format. This does include all global timers (\see
+/// Timer, TimerGroup). Note that the timers are cleared after printing and will
+/// not be printed in human readable form or in a second call of
+/// PrintStatisticsJSON().
void PrintStatisticsJSON(raw_ostream &OS);
} // end namespace llvm
diff --git a/llvm/include/llvm/Support/Timer.h b/llvm/include/llvm/Support/Timer.h
index 00e437f908a..80e8f13dccf 100644
--- a/llvm/include/llvm/Support/Timer.h
+++ b/llvm/include/llvm/Support/Timer.h
@@ -168,10 +168,24 @@ struct NamedRegionTimer : public TimeRegion {
/// destroy a TimerGroup object before all of the Timers in it are gone. A
/// TimerGroup can be specified for a newly created timer in its constructor.
class TimerGroup {
+ struct PrintRecord {
+ TimeRecord Time;
+ std::string Name;
+ std::string Description;
+
+ PrintRecord(const PrintRecord &Other) = default;
+ PrintRecord(const TimeRecord &Time, const std::string &Name,
+ const std::string &Description)
+ : Time(Time), Name(Name), Description(Description) {}
+
+ bool operator <(const PrintRecord &Other) const {
+ return Time < Other.Time;
+ }
+ };
std::string Name;
std::string Description;
Timer *FirstTimer = nullptr; ///< First timer in the group.
- std::vector<std::pair<TimeRecord, std::string>> TimersToPrint;
+ std::vector<PrintRecord> TimersToPrint;
TimerGroup **Prev; ///< Pointer to Next field of previous timergroup in list.
TimerGroup *Next; ///< Pointer to next timergroup in list.
@@ -193,11 +207,21 @@ public:
/// This static method prints all timers and clears them all out.
static void printAll(raw_ostream &OS);
+ /// Ensure global timer group lists are initialized. This function is mostly
+ /// used by the Statistic code to influence the construction and destruction
+ /// order of the global timer lists.
+ static void ConstructTimerLists();
private:
friend class Timer;
+ friend void PrintStatisticsJSON(raw_ostream &OS);
void addTimer(Timer &T);
void removeTimer(Timer &T);
+ void prepareToPrintList();
void PrintQueuedTimers(raw_ostream &OS);
+ void printJSONValue(raw_ostream &OS, const PrintRecord &R,
+ const char *suffix, double Value);
+ const char *printJSONValues(raw_ostream &OS, const char *delim);
+ static const char *printAllJSONValues(raw_ostream &OS, const char *delim);
};
} // end namespace llvm
OpenPOWER on IntegriCloud