Make each stat take up one full line. This allows us to use grep

to find and remove stats from the files so we can put less
burden on the python interpreter.

base/statistics.cc:
    Manually insert newlines into the python code so that we now have one
    stat per line.  (Make it so we can use grep -v to remove stats)
test/stattest.cc:
    update to reflect changes in how python is accessed

--HG--
extra : convert_revision : 554edcf9c795b33d00d3d15554447c8accebebfa
This commit is contained in:
Nathan Binkert 2004-01-15 16:33:58 -05:00
parent 81575e74e7
commit c9f2aa8c18
2 changed files with 37 additions and 27 deletions

View file

@ -116,7 +116,7 @@ Data::~Data()
{ {
if (stream) { if (stream) {
delete py; delete py;
ccprintf(*stream, "if __name__ == '__main__':\n"); ccprintf(*stream, "\n\nif __name__ == '__main__':\n");
ccprintf(*stream, " program_display()\n"); ccprintf(*stream, " program_display()\n");
stream->close(); stream->close();
delete stream; delete stream;
@ -209,30 +209,42 @@ Data::python_dump(const string &name, const string &subname)
++i; ++i;
} }
} }
py->next(); // py->next();
} }
void void
Data::python(const string &name, const string &subname, const string &bin) Data::python(const string &name, const string &subname, const string &bin)
{ {
py->start("collections.append"); py->name("collections.append");
py->start("Collection"); py->newline();
py->name("Collection");
py->newline();
py->qarg(name); py->qarg(name);
py->newline();
py->qarg(subname); py->qarg(subname);
py->newline();
py->qarg(bin); py->qarg(bin);
py->newline();
py->qarg(hostname()); py->qarg(hostname());
py->newline();
py->qarg(Time::start.date()); py->qarg(Time::start.date());
py->startList(); py->newline();
py->list();
list_t::iterator i = allStats.begin(); list_t::iterator i = allStats.begin();
list_t::iterator end = allStats.end(); list_t::iterator end = allStats.end();
while (i != end) { while (i != end) {
StatData *stat = *i; StatData *stat = *i;
py->newline();
stat->python(*py); stat->python(*py);
++i; ++i;
} }
py->endList(); py->newline();
py->end(); py->listEnd();
py->end(); py->newline();
py->nameEnd();
py->newline();
py->nameEnd();
py->newline();
} }
StatData * StatData *
@ -996,7 +1008,7 @@ VectorDistDataBase::display(ostream &stream, DisplayMode mode) const
void void
ScalarDataBase::python(Python &py) const ScalarDataBase::python(Python &py) const
{ {
py.start("Scalar"); py.name("Scalar");
py.qarg(name); py.qarg(name);
py.qqqarg(desc); py.qqqarg(desc);
py.kwarg("binned", binned()); py.kwarg("binned", binned());
@ -1005,7 +1017,7 @@ ScalarDataBase::python(Python &py) const
if (prereq) if (prereq)
py.qkwarg("prereq", prereq->name); py.qkwarg("prereq", prereq->name);
py.kwarg("value", val()); py.kwarg("value", val());
py.end(); py.nameEnd();
} }
void void
@ -1013,7 +1025,7 @@ VectorDataBase::python(Python &py) const
{ {
const_cast<VectorDataBase *>(this)->update(); const_cast<VectorDataBase *>(this)->update();
py.start("Vector"); py.name("Vector");
py.qarg(name); py.qarg(name);
py.qqqarg(desc); py.qqqarg(desc);
py.kwarg("binned", binned()); py.kwarg("binned", binned());
@ -1026,7 +1038,7 @@ VectorDataBase::python(Python &py) const
py.qkwarg("subnames", subnames); py.qkwarg("subnames", subnames);
if (!subdescs.empty()) if (!subdescs.empty())
py.qkwarg("subdescs", subdescs); py.qkwarg("subdescs", subdescs);
py.end(); py.nameEnd();
} }
void void
@ -1039,7 +1051,7 @@ DistDataData::python(Python &py, const string &name) const
else else
s += "FullDist"; s += "FullDist";
py.start(s); py.name(s);
py.arg(sum); py.arg(sum);
py.arg(squares); py.arg(squares);
py.arg(samples); py.arg(samples);
@ -1054,7 +1066,7 @@ DistDataData::python(Python &py, const string &name) const
py.arg(bucket_size); py.arg(bucket_size);
py.arg(size); py.arg(size);
} }
py.end(); py.nameEnd();
} }
void void
@ -1062,7 +1074,7 @@ FormulaDataBase::python(Python &py) const
{ {
const_cast<FormulaDataBase *>(this)->update(); const_cast<FormulaDataBase *>(this)->update();
py.start("Formula"); py.name("Formula");
py.qarg(name); py.qarg(name);
py.qqqarg(desc); py.qqqarg(desc);
py.kwarg("binned", binned()); py.kwarg("binned", binned());
@ -1075,7 +1087,7 @@ FormulaDataBase::python(Python &py) const
py.qkwarg("subnames", subnames); py.qkwarg("subnames", subnames);
if (!subdescs.empty()) if (!subdescs.empty())
py.qkwarg("subdescs", subdescs); py.qkwarg("subdescs", subdescs);
py.end(); py.nameEnd();
} }
void void
@ -1083,7 +1095,7 @@ DistDataBase::python(Python &py) const
{ {
const_cast<DistDataBase *>(this)->update(); const_cast<DistDataBase *>(this)->update();
py.start("Dist"); py.name("Dist");
py.qarg(name); py.qarg(name);
py.qqqarg(desc); py.qqqarg(desc);
py.kwarg("binned", binned()); py.kwarg("binned", binned());
@ -1092,7 +1104,7 @@ DistDataBase::python(Python &py) const
if (prereq) if (prereq)
py.qkwarg("prereq", prereq->name); py.qkwarg("prereq", prereq->name);
data.python(py, "dist"); data.python(py, "dist");
py.end(); py.nameEnd();
} }
void void
@ -1100,7 +1112,7 @@ VectorDistDataBase::python(Python &py) const
{ {
const_cast<VectorDistDataBase *>(this)->update(); const_cast<VectorDistDataBase *>(this)->update();
py.start("VectorDist"); py.name("VectorDist");
py.qarg(name); py.qarg(name);
py.qqqarg(desc); py.qqqarg(desc);
py.kwarg("binned", binned()); py.kwarg("binned", binned());
@ -1121,8 +1133,8 @@ VectorDistDataBase::python(Python &py) const
i->python(py, ""); i->python(py, "");
++i; ++i;
} }
py.endTuple(); py.tupleEnd();
py.end(); py.nameEnd();
} }
void void
@ -1130,7 +1142,7 @@ Vector2dDataBase::python(Python &py) const
{ {
const_cast<Vector2dDataBase *>(this)->update(); const_cast<Vector2dDataBase *>(this)->update();
py.start("Vector2d"); py.name("Vector2d");
py.qarg(name); py.qarg(name);
py.qqqarg(desc); py.qqqarg(desc);
py.kwarg("binned", binned()); py.kwarg("binned", binned());
@ -1149,7 +1161,7 @@ Vector2dDataBase::python(Python &py) const
py.kwarg("x", x); py.kwarg("x", x);
py.kwarg("y", y); py.kwarg("y", y);
py.end(); py.nameEnd();
} }
void void

View file

@ -510,10 +510,8 @@ main(int argc, char *argv[])
s12.sample(100); s12.sample(100);
// dump(cout, mode_simplescalar); // dump(cout, mode_simplescalar);
ofstream file("/tmp/stats.py"); python_start("/tmp/stats.py");
dump(file, "stattest", mode_python); python_dump("stattest", "all");
file.close();
return 0; return 0;
} }