@@ -34,6 +34,9 @@ using namespace detail;
34
34
using DisplayMode = DefaultTimingManager::DisplayMode;
35
35
using OutputFormat = DefaultTimingManager::OutputFormat;
36
36
37
+ constexpr llvm::StringLiteral kTimingDescription =
38
+ " ... Execution time report ..." ;
39
+
37
40
// ===----------------------------------------------------------------------===//
38
41
// TimingManager
39
42
// ===----------------------------------------------------------------------===//
@@ -107,6 +110,50 @@ TimingIdentifier TimingIdentifier::get(StringRef str, TimingManager &tm) {
107
110
108
111
namespace {
109
112
113
+ class OutputTextStrategy : public OutputStrategy {
114
+ public:
115
+ OutputTextStrategy (raw_ostream &os) : OutputStrategy(os) {}
116
+
117
+ void printHeader (const TimeRecord &total) override {
118
+ // Figure out how many spaces to description name.
119
+ unsigned padding = (80 - kTimingDescription .size ()) / 2 ;
120
+ os << " ===" << std::string (73 , ' -' ) << " ===\n " ;
121
+ os.indent (padding) << kTimingDescription << ' \n ' ;
122
+ os << " ===" << std::string (73 , ' -' ) << " ===\n " ;
123
+
124
+ // Print the total time followed by the section headers.
125
+ os << llvm::format (" Total Execution Time: %.4f seconds\n\n " , total.wall );
126
+ if (total.user != total.wall )
127
+ os << " ----User Time----" ;
128
+ os << " ----Wall Time---- ----Name----\n " ;
129
+ }
130
+
131
+ void printFooter () override { os.flush (); }
132
+
133
+ void printTime (const TimeRecord &time, const TimeRecord &total) override {
134
+ if (total.user != total.wall ) {
135
+ os << llvm::format (" %8.4f (%5.1f%%)" , time.user ,
136
+ 100.0 * time.user / total.user );
137
+ }
138
+ os << llvm::format (" %8.4f (%5.1f%%) " , time.wall ,
139
+ 100.0 * time.wall / total.wall );
140
+ }
141
+
142
+ void printListEntry (StringRef name, const TimeRecord &time,
143
+ const TimeRecord &total, bool lastEntry) override {
144
+ printTime (time, total);
145
+ os << name << " \n " ;
146
+ }
147
+
148
+ void printTreeEntry (unsigned indent, StringRef name, const TimeRecord &time,
149
+ const TimeRecord &total) override {
150
+ printTime (time, total);
151
+ os.indent (indent) << name << " \n " ;
152
+ }
153
+
154
+ void printTreeEntryEnd (unsigned indent, bool lastEntry) override {}
155
+ };
156
+
110
157
class OutputJsonStrategy : public OutputStrategy {
111
158
public:
112
159
OutputJsonStrategy (raw_ostream &os) : OutputStrategy(os) {}
0 commit comments