/*
- * Copyright (c) 2019 Arm Limited
+ * Copyright (c) 2019-2020 Arm Limited
* All rights reserved.
*
* The license below extends only to copyright in the software and shall
std::list<Info *> &statsList();
Text::Text()
- : mystream(false), stream(NULL), descriptions(false)
+ : mystream(false), stream(NULL), descriptions(false), spaces(false)
{
}
-Text::Text(std::ostream &stream)
- : mystream(false), stream(NULL), descriptions(false)
+Text::Text(std::ostream &stream) : Text()
{
open(stream);
}
-Text::Text(const std::string &file)
- : mystream(false), stream(NULL), descriptions(false)
+Text::Text(const std::string &file) : Text()
{
open(file);
}
string desc;
Flags flags;
bool descriptions;
+ bool spaces;
int precision;
Result pdf;
Result cdf;
-
+ int nameSpaces;
+ int valueSpaces;
+ int pdfstrSpaces;
+ int cdfstrSpaces;
+
+ ScalarPrint(bool spaces) : spaces(spaces) {
+ if (spaces) {
+ nameSpaces = 40;
+ valueSpaces = 12;
+ pdfstrSpaces = 10;
+ cdfstrSpaces = 10;
+ } else {
+ nameSpaces = 0;
+ valueSpaces = 0;
+ pdfstrSpaces = 0;
+ cdfstrSpaces = 0;
+ }
+ }
void update(Result val, Result total);
void operator()(ostream &stream, bool oneLine = false) const;
};
ccprintf(cdfstr, "%.2f%%", cdf * 100.0);
if (oneLine) {
- ccprintf(stream, " |%12s %10s %10s",
- ValueToString(value, precision), pdfstr.str(), cdfstr.str());
+ ccprintf(stream, " |");
} else {
- ccprintf(stream, "%-40s %12s %10s %10s", name,
- ValueToString(value, precision), pdfstr.str(), cdfstr.str());
-
+ ccprintf(stream, "%-*s ", nameSpaces, name);
+ }
+ ccprintf(stream, "%*s", valueSpaces, ValueToString(value, precision));
+ if (spaces || pdfstr.rdbuf()->in_avail())
+ ccprintf(stream, " %*s", pdfstrSpaces, pdfstr.str());
+ if (spaces || cdfstr.rdbuf()->in_avail())
+ ccprintf(stream, " %*s", cdfstrSpaces, cdfstr.str());
+ if (!oneLine) {
if (descriptions) {
if (!desc.empty())
ccprintf(stream, " # %s", desc);
vector<string> subdescs;
Flags flags;
bool descriptions;
+ bool spaces;
int precision;
VResult vec;
Result total;
bool forceSubnames;
-
+ int nameSpaces;
+
+ VectorPrint() = delete;
+ VectorPrint(bool spaces) : spaces(spaces) {
+ if (spaces) {
+ nameSpaces = 40;
+ } else {
+ nameSpaces = 0;
+ }
+ }
void operator()(ostream &stream) const;
};
string base = name + separatorString;
- ScalarPrint print;
+ ScalarPrint print(spaces);
print.name = name;
print.desc = desc;
print.precision = precision;
if ((!flags.isSet(nozero)) || (total != 0)) {
if (flags.isSet(oneline)) {
- ccprintf(stream, "%-40s", name);
+ ccprintf(stream, "%-*s", nameSpaces, name);
print.flags = print.flags & (~nozero);
}
string desc;
Flags flags;
bool descriptions;
+ bool spaces;
int precision;
+ int nameSpaces;
const DistData &data;
init(text, info);
}
-DistPrint::DistPrint(const Text *text, const VectorDistInfo &info, int i)
- : data(info.data[i])
+DistPrint::DistPrint(const Text *text, const VectorDistInfo &info,
+ int i) : data(info.data[i])
{
init(text, info);
flags = info.flags;
precision = info.precision;
descriptions = text->descriptions;
+ spaces = text->spaces;
+ if (spaces) {
+ nameSpaces = 40;
+ } else {
+ nameSpaces = 0;
+ }
}
void
if (flags.isSet(nozero) && data.samples == 0) return;
string base = name + separatorString;
- ScalarPrint print;
+ ScalarPrint print(spaces);
print.precision = precision;
print.flags = flags;
print.descriptions = descriptions;
}
if (flags.isSet(oneline)) {
- ccprintf(stream, "%-40s", name);
+ ccprintf(stream, "%-*s", nameSpaces, name);
}
for (off_type i = 0; i < size; ++i) {
if (noOutput(info))
return;
- ScalarPrint print;
+ ScalarPrint print(spaces);
print.value = info.result();
print.name = statName(info.name);
print.desc = info.desc;
return;
size_type size = info.size();
- VectorPrint print;
+ VectorPrint print(spaces);
print.name = statName(info.name);
print.separatorString = info.separatorString;
return;
bool havesub = false;
- VectorPrint print;
+ VectorPrint print(spaces);
if (!info.y_subnames.empty()) {
for (off_type i = 0; i < info.y; ++i) {
string desc;
Flags flags;
bool descriptions;
+ bool spaces;
int precision;
const SparseHistData &data;
flags = info.flags;
precision = info.precision;
descriptions = text->descriptions;
+ spaces = text->spaces;
}
/* Grab data from map and write to output stream */
{
string base = name + separatorString;
- ScalarPrint print;
+ ScalarPrint print(spaces);
print.precision = precision;
print.flags = flags;
print.descriptions = descriptions;
}
Output *
-initText(const string &filename, bool desc)
+initText(const string &filename, bool desc, bool spaces)
{
static Text text;
static bool connected = false;
if (!connected) {
text.open(*simout.findOrCreate(filename)->stream());
text.descriptions = desc;
+ text.spaces = spaces;
connected = true;
}
-# Copyright (c) 2017-2019 ARM Limited
+# Copyright (c) 2017-2020 ARM Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
return decorator
@_url_factory([ None, "", "text", "file", ])
-def _textFactory(fn, desc=True):
+def _textFactory(fn, desc=True, spaces=True):
"""Output stats in text format.
Text stat files contain one stat per line with an optional
Parameters:
* desc (bool): Output stat descriptions (default: True)
+ * spaces (bool): Output alignment spaces (default: True)
Example:
- text://stats.txt?desc=False
+ text://stats.txt?desc=False;spaces=False
"""
- return _m5.stats.initText(fn, desc)
+ return _m5.stats.initText(fn, desc, spaces)
@_url_factory([ "h5", ], enable=hasattr(_m5.stats, "initHDF5"))
def _hdf5Factory(fn, chunking=10, desc=True, formulas=True):