stats: add option to disable alignment spaces in stats.txt file
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>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -95,18 +95,16 @@ namespace Stats {
|
||||
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);
|
||||
}
|
||||
@@ -229,10 +227,28 @@ struct ScalarPrint
|
||||
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;
|
||||
};
|
||||
@@ -263,12 +279,16 @@ ScalarPrint::operator()(ostream &stream, bool oneLine) 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);
|
||||
@@ -286,11 +306,21 @@ struct VectorPrint
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -308,7 +338,7 @@ VectorPrint::operator()(std::ostream &stream) const
|
||||
|
||||
string base = name + separatorString;
|
||||
|
||||
ScalarPrint print;
|
||||
ScalarPrint print(spaces);
|
||||
print.name = name;
|
||||
print.desc = desc;
|
||||
print.precision = precision;
|
||||
@@ -332,7 +362,7 @@ VectorPrint::operator()(std::ostream &stream) const
|
||||
|
||||
if ((!flags.isSet(nozero)) || (total != 0)) {
|
||||
if (flags.isSet(oneline)) {
|
||||
ccprintf(stream, "%-40s", name);
|
||||
ccprintf(stream, "%-*s", nameSpaces, name);
|
||||
print.flags = print.flags & (~nozero);
|
||||
}
|
||||
|
||||
@@ -373,7 +403,9 @@ struct DistPrint
|
||||
string desc;
|
||||
Flags flags;
|
||||
bool descriptions;
|
||||
bool spaces;
|
||||
int precision;
|
||||
int nameSpaces;
|
||||
|
||||
const DistData &data;
|
||||
|
||||
@@ -389,8 +421,8 @@ DistPrint::DistPrint(const Text *text, const DistInfo &info)
|
||||
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);
|
||||
|
||||
@@ -411,6 +443,12 @@ DistPrint::init(const Text *text, const Info &info)
|
||||
flags = info.flags;
|
||||
precision = info.precision;
|
||||
descriptions = text->descriptions;
|
||||
spaces = text->spaces;
|
||||
if (spaces) {
|
||||
nameSpaces = 40;
|
||||
} else {
|
||||
nameSpaces = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -419,7 +457,7 @@ DistPrint::operator()(ostream &stream) const
|
||||
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;
|
||||
@@ -488,7 +526,7 @@ DistPrint::operator()(ostream &stream) const
|
||||
}
|
||||
|
||||
if (flags.isSet(oneline)) {
|
||||
ccprintf(stream, "%-40s", name);
|
||||
ccprintf(stream, "%-*s", nameSpaces, name);
|
||||
}
|
||||
|
||||
for (off_type i = 0; i < size; ++i) {
|
||||
@@ -546,7 +584,7 @@ Text::visit(const ScalarInfo &info)
|
||||
if (noOutput(info))
|
||||
return;
|
||||
|
||||
ScalarPrint print;
|
||||
ScalarPrint print(spaces);
|
||||
print.value = info.result();
|
||||
print.name = statName(info.name);
|
||||
print.desc = info.desc;
|
||||
@@ -566,7 +604,7 @@ Text::visit(const VectorInfo &info)
|
||||
return;
|
||||
|
||||
size_type size = info.size();
|
||||
VectorPrint print;
|
||||
VectorPrint print(spaces);
|
||||
|
||||
print.name = statName(info.name);
|
||||
print.separatorString = info.separatorString;
|
||||
@@ -606,7 +644,7 @@ Text::visit(const Vector2dInfo &info)
|
||||
return;
|
||||
|
||||
bool havesub = false;
|
||||
VectorPrint print;
|
||||
VectorPrint print(spaces);
|
||||
|
||||
if (!info.y_subnames.empty()) {
|
||||
for (off_type i = 0; i < info.y; ++i) {
|
||||
@@ -705,6 +743,7 @@ struct SparseHistPrint
|
||||
string desc;
|
||||
Flags flags;
|
||||
bool descriptions;
|
||||
bool spaces;
|
||||
int precision;
|
||||
|
||||
const SparseHistData &data;
|
||||
@@ -731,6 +770,7 @@ SparseHistPrint::init(const Text *text, const Info &info)
|
||||
flags = info.flags;
|
||||
precision = info.precision;
|
||||
descriptions = text->descriptions;
|
||||
spaces = text->spaces;
|
||||
}
|
||||
|
||||
/* Grab data from map and write to output stream */
|
||||
@@ -739,7 +779,7 @@ SparseHistPrint::operator()(ostream &stream) const
|
||||
{
|
||||
string base = name + separatorString;
|
||||
|
||||
ScalarPrint print;
|
||||
ScalarPrint print(spaces);
|
||||
print.precision = precision;
|
||||
print.flags = flags;
|
||||
print.descriptions = descriptions;
|
||||
@@ -774,7 +814,7 @@ Text::visit(const SparseHistInfo &info)
|
||||
}
|
||||
|
||||
Output *
|
||||
initText(const string &filename, bool desc)
|
||||
initText(const string &filename, bool desc, bool spaces)
|
||||
{
|
||||
static Text text;
|
||||
static bool connected = false;
|
||||
@@ -782,6 +822,7 @@ initText(const string &filename, bool desc)
|
||||
if (!connected) {
|
||||
text.open(*simout.findOrCreate(filename)->stream());
|
||||
text.descriptions = desc;
|
||||
text.spaces = spaces;
|
||||
connected = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -65,6 +65,7 @@ class Text : public Output
|
||||
|
||||
public:
|
||||
bool descriptions;
|
||||
bool spaces;
|
||||
|
||||
public:
|
||||
Text();
|
||||
@@ -97,7 +98,7 @@ class Text : public Output
|
||||
|
||||
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);
|
||||
|
||||
} // namespace Stats
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# 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
|
||||
@@ -131,7 +131,7 @@ def _url_factory(schemes, enable=True):
|
||||
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
|
||||
@@ -140,13 +140,14 @@ def _textFactory(fn, desc=True):
|
||||
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user