Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions mlir/include/mlir/Support/Timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMapEntry.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Format.h"
#include <optional>

namespace mlir {
Expand Down Expand Up @@ -368,53 +367,6 @@ class OutputStrategy {
raw_ostream &os;
};

constexpr llvm::StringLiteral kTimingDescription =
"... Execution time report ...";

class OutputTextStrategy : public OutputStrategy {
public:
OutputTextStrategy(raw_ostream &os) : OutputStrategy(os) {}

void printHeader(const TimeRecord &total) override {
// Figure out how many spaces to description name.
unsigned padding = (80 - kTimingDescription.size()) / 2;
os << "===" << std::string(73, '-') << "===\n";
os.indent(padding) << kTimingDescription << '\n';
os << "===" << std::string(73, '-') << "===\n";

// Print the total time followed by the section headers.
os << llvm::format(" Total Execution Time: %.4f seconds\n\n", total.wall);
if (total.user != total.wall)
os << " ----User Time----";
os << " ----Wall Time---- ----Name----\n";
}

void printFooter() override { os.flush(); }

void printTime(const TimeRecord &time, const TimeRecord &total) override {
if (total.user != total.wall) {
os << llvm::format(" %8.4f (%5.1f%%)", time.user,
100.0 * time.user / total.user);
}
os << llvm::format(" %8.4f (%5.1f%%) ", time.wall,
100.0 * time.wall / total.wall);
}

void printListEntry(StringRef name, const TimeRecord &time,
const TimeRecord &total, bool lastEntry) override {
printTime(time, total);
os << name << "\n";
}

void printTreeEntry(unsigned indent, StringRef name, const TimeRecord &time,
const TimeRecord &total) override {
printTime(time, total);
os.indent(indent) << name << "\n";
}

void printTreeEntryEnd(unsigned indent, bool lastEntry) override {}
};

//===----------------------------------------------------------------------===//
// DefaultTimingManager
//===----------------------------------------------------------------------===//
Expand Down
47 changes: 47 additions & 0 deletions mlir/lib/Support/Timing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ using namespace detail;
using DisplayMode = DefaultTimingManager::DisplayMode;
using OutputFormat = DefaultTimingManager::OutputFormat;

constexpr llvm::StringLiteral kTimingDescription =
"... Execution time report ...";

//===----------------------------------------------------------------------===//
// TimingManager
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -107,6 +110,50 @@ TimingIdentifier TimingIdentifier::get(StringRef str, TimingManager &tm) {

namespace {

class OutputTextStrategy : public OutputStrategy {
public:
OutputTextStrategy(raw_ostream &os) : OutputStrategy(os) {}

void printHeader(const TimeRecord &total) override {
// Figure out how many spaces to description name.
unsigned padding = (80 - kTimingDescription.size()) / 2;
os << "===" << std::string(73, '-') << "===\n";
os.indent(padding) << kTimingDescription << '\n';
os << "===" << std::string(73, '-') << "===\n";

// Print the total time followed by the section headers.
os << llvm::format(" Total Execution Time: %.4f seconds\n\n", total.wall);
if (total.user != total.wall)
os << " ----User Time----";
os << " ----Wall Time---- ----Name----\n";
}

void printFooter() override { os.flush(); }

void printTime(const TimeRecord &time, const TimeRecord &total) override {
if (total.user != total.wall) {
os << llvm::format(" %8.4f (%5.1f%%)", time.user,
100.0 * time.user / total.user);
}
os << llvm::format(" %8.4f (%5.1f%%) ", time.wall,
100.0 * time.wall / total.wall);
}

void printListEntry(StringRef name, const TimeRecord &time,
const TimeRecord &total, bool lastEntry) override {
printTime(time, total);
os << name << "\n";
}

void printTreeEntry(unsigned indent, StringRef name, const TimeRecord &time,
const TimeRecord &total) override {
printTime(time, total);
os.indent(indent) << name << "\n";
}

void printTreeEntryEnd(unsigned indent, bool lastEntry) override {}
};

class OutputJsonStrategy : public OutputStrategy {
public:
OutputJsonStrategy(raw_ostream &os) : OutputStrategy(os) {}
Expand Down
Loading