The alignment spaces in stats.txt takes up a lot of space and increases
simulation time, this commit adds the option to disable them with:
--stats-file stats.txt?spaces=False
Sample old lines with ?desc=False:
system.cpu.op_class::FloatMultAcc 0 0.00% 65.92%
system.cpu.op_class::FloatDiv 0 0.00% 65.92%
Sample new lines with ?desc=False;spaces=False:
system.cpu.op_class::FloatMultAcc 0 0.00% 65.92%
system.cpu.op_class::FloatDiv 0 0.00% 65.92%
On a 1000 dumpstats m5op loop spaces=False reduces:
* size: from 38MB to 20MB
* time: from 4.5s to 3.5s
Change-Id: Ib738b996b5646c329094cf61aaa1d977e844e759
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/28627
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
- * 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
* All rights reserved.
*
* The license below extends only to copyright in the software and shall
std::list<Info *> &statsList();
Text::Text()
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()
-Text::Text(const std::string &file)
- : mystream(false), stream(NULL), descriptions(false)
+Text::Text(const std::string &file) : Text()
string desc;
Flags flags;
bool descriptions;
string desc;
Flags flags;
bool descriptions;
int precision;
Result pdf;
Result cdf;
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;
};
void update(Result val, Result total);
void operator()(ostream &stream, bool oneLine = false) const;
};
ccprintf(cdfstr, "%.2f%%", cdf * 100.0);
if (oneLine) {
ccprintf(cdfstr, "%.2f%%", cdf * 100.0);
if (oneLine) {
- ccprintf(stream, " |%12s %10s %10s",
- ValueToString(value, precision), pdfstr.str(), cdfstr.str());
+ ccprintf(stream, " |");
- 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);
if (descriptions) {
if (!desc.empty())
ccprintf(stream, " # %s", desc);
vector<string> subdescs;
Flags flags;
bool descriptions;
vector<string> subdescs;
Flags flags;
bool descriptions;
int precision;
VResult vec;
Result total;
bool forceSubnames;
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;
};
void operator()(ostream &stream) const;
};
string base = name + separatorString;
string base = name + separatorString;
+ ScalarPrint print(spaces);
print.name = name;
print.desc = desc;
print.precision = precision;
print.name = name;
print.desc = desc;
print.precision = precision;
if ((!flags.isSet(nozero)) || (total != 0)) {
if (flags.isSet(oneline)) {
if ((!flags.isSet(nozero)) || (total != 0)) {
if (flags.isSet(oneline)) {
- ccprintf(stream, "%-40s", name);
+ ccprintf(stream, "%-*s", nameSpaces, name);
print.flags = print.flags & (~nozero);
}
print.flags = print.flags & (~nozero);
}
string desc;
Flags flags;
bool descriptions;
string desc;
Flags flags;
bool descriptions;
-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])
flags = info.flags;
precision = info.precision;
descriptions = text->descriptions;
flags = info.flags;
precision = info.precision;
descriptions = text->descriptions;
+ spaces = text->spaces;
+ if (spaces) {
+ nameSpaces = 40;
+ } else {
+ nameSpaces = 0;
+ }
if (flags.isSet(nozero) && data.samples == 0) return;
string base = name + separatorString;
if (flags.isSet(nozero) && data.samples == 0) return;
string base = name + separatorString;
+ ScalarPrint print(spaces);
print.precision = precision;
print.flags = flags;
print.descriptions = descriptions;
print.precision = precision;
print.flags = flags;
print.descriptions = descriptions;
}
if (flags.isSet(oneline)) {
}
if (flags.isSet(oneline)) {
- ccprintf(stream, "%-40s", name);
+ ccprintf(stream, "%-*s", nameSpaces, name);
}
for (off_type i = 0; i < size; ++i) {
}
for (off_type i = 0; i < size; ++i) {
if (noOutput(info))
return;
if (noOutput(info))
return;
+ ScalarPrint print(spaces);
print.value = info.result();
print.name = statName(info.name);
print.desc = info.desc;
print.value = info.result();
print.name = statName(info.name);
print.desc = info.desc;
return;
size_type size = info.size();
return;
size_type size = info.size();
+ VectorPrint print(spaces);
print.name = statName(info.name);
print.separatorString = info.separatorString;
print.name = statName(info.name);
print.separatorString = info.separatorString;
return;
bool havesub = false;
return;
bool havesub = false;
+ VectorPrint print(spaces);
if (!info.y_subnames.empty()) {
for (off_type i = 0; i < info.y; ++i) {
if (!info.y_subnames.empty()) {
for (off_type i = 0; i < info.y; ++i) {
string desc;
Flags flags;
bool descriptions;
string desc;
Flags flags;
bool descriptions;
int precision;
const SparseHistData &data;
int precision;
const SparseHistData &data;
flags = info.flags;
precision = info.precision;
descriptions = text->descriptions;
flags = info.flags;
precision = info.precision;
descriptions = text->descriptions;
}
/* Grab data from map and write to output stream */
}
/* Grab data from map and write to output stream */
{
string base = name + separatorString;
{
string base = name + separatorString;
+ ScalarPrint print(spaces);
print.precision = precision;
print.flags = flags;
print.descriptions = descriptions;
print.precision = precision;
print.flags = flags;
print.descriptions = descriptions;
-initText(const string &filename, bool desc)
+initText(const string &filename, bool desc, bool spaces)
{
static Text text;
static bool connected = false;
{
static Text text;
static bool connected = false;
if (!connected) {
text.open(*simout.findOrCreate(filename)->stream());
text.descriptions = desc;
if (!connected) {
text.open(*simout.findOrCreate(filename)->stream());
text.descriptions = desc;
- * 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
* All rights reserved.
*
* The license below extends only to copyright in the software and shall
public:
bool descriptions;
public:
bool descriptions;
std::string ValueToString(Result value, int precision);
std::string ValueToString(Result value, int precision);
-Output *initText(const std::string &filename, bool desc);
+Output *initText(const std::string &filename, bool desc, bool spaces);
-# 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
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
return decorator
@_url_factory([ None, "", "text", "file", ])
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
"""Output stats in text format.
Text stat files contain one stat per line with an optional
Parameters:
* desc (bool): Output stat descriptions (default: True)
Parameters:
* desc (bool): Output stat descriptions (default: True)
+ * spaces (bool): Output alignment spaces (default: True)
- 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):
@_url_factory([ "h5", ], enable=hasattr(_m5.stats, "initHDF5"))
def _hdf5Factory(fn, chunking=10, desc=True, formulas=True):