2004-05-04 23:01:00 +02:00
|
|
|
/*
|
2005-06-05 11:16:00 +02:00
|
|
|
* Copyright (c) 2004-2005 The Regents of The University of Michigan
|
2004-05-04 23:01:00 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2006-06-01 01:26:56 +02:00
|
|
|
*
|
|
|
|
* Authors: Nathan Binkert
|
2004-05-04 23:01:00 +02:00
|
|
|
*/
|
|
|
|
|
2004-06-21 06:58:30 +02:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
#define _GLIBCPP_USE_C99 1
|
|
|
|
#endif
|
|
|
|
|
2007-01-27 00:48:51 +01:00
|
|
|
#if defined(__sun)
|
|
|
|
#include <math.h>
|
|
|
|
#endif
|
|
|
|
|
2004-05-04 23:01:00 +02:00
|
|
|
#include <iostream>
|
2006-05-16 02:06:42 +02:00
|
|
|
#include <sstream>
|
2004-05-04 23:01:00 +02:00
|
|
|
#include <fstream>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "base/misc.hh"
|
|
|
|
#include "base/statistics.hh"
|
|
|
|
#include "base/stats/text.hh"
|
|
|
|
#include "base/stats/visit.hh"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#ifndef NAN
|
|
|
|
float __nan();
|
|
|
|
/** Define Not a number. */
|
|
|
|
#define NAN (__nan())
|
|
|
|
/** Need to define __nan() */
|
|
|
|
#define __M5_NAN
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __M5_NAN
|
|
|
|
float
|
|
|
|
__nan()
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
uint32_t ui;
|
|
|
|
float f;
|
|
|
|
} nan;
|
|
|
|
|
|
|
|
nan.ui = 0x7fc00000;
|
|
|
|
return nan.f;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-05-21 19:39:20 +02:00
|
|
|
namespace Stats {
|
2004-05-04 23:01:00 +02:00
|
|
|
|
|
|
|
Text::Text()
|
|
|
|
: mystream(false), stream(NULL), compat(false), descriptions(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Text::Text(std::ostream &stream)
|
|
|
|
: mystream(false), stream(NULL), compat(false), descriptions(false)
|
|
|
|
{
|
|
|
|
open(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
Text::Text(const std::string &file)
|
|
|
|
: mystream(false), stream(NULL), compat(false), descriptions(false)
|
|
|
|
{
|
|
|
|
open(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Text::~Text()
|
|
|
|
{
|
|
|
|
if (mystream) {
|
|
|
|
assert(stream);
|
|
|
|
delete stream;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Text::open(std::ostream &_stream)
|
|
|
|
{
|
|
|
|
if (stream)
|
|
|
|
panic("stream already set!");
|
|
|
|
|
|
|
|
mystream = false;
|
|
|
|
stream = &_stream;
|
2008-10-02 18:46:57 +02:00
|
|
|
if (!valid())
|
|
|
|
fatal("Unable to open output stream for writing\n");
|
2004-05-04 23:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Text::open(const std::string &file)
|
|
|
|
{
|
|
|
|
if (stream)
|
|
|
|
panic("stream already set!");
|
|
|
|
|
|
|
|
mystream = true;
|
|
|
|
stream = new ofstream(file.c_str(), ios::trunc);
|
2008-10-02 18:46:57 +02:00
|
|
|
if (!valid())
|
|
|
|
fatal("Unable to open statistics file for writing\n");
|
2004-05-04 23:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Text::valid() const
|
|
|
|
{
|
2008-10-02 18:46:57 +02:00
|
|
|
return stream != NULL && stream->good();
|
2004-05-04 23:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Text::output()
|
|
|
|
{
|
|
|
|
ccprintf(*stream, "\n---------- Begin Simulation Statistics ----------\n");
|
2009-02-23 21:22:17 +01:00
|
|
|
list<Info *>::const_iterator i, end = statsList().end();
|
|
|
|
for (i = statsList().begin(); i != end; ++i)
|
2006-06-10 19:08:43 +02:00
|
|
|
(*i)->visit(*this);
|
2004-05-04 23:01:00 +02:00
|
|
|
ccprintf(*stream, "\n---------- End Simulation Statistics ----------\n");
|
|
|
|
stream->flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2009-02-23 21:22:15 +01:00
|
|
|
Text::noOutput(const Info &info)
|
2004-05-04 23:01:00 +02:00
|
|
|
{
|
2009-02-23 21:22:15 +01:00
|
|
|
if (!(info.flags & print))
|
2004-05-04 23:01:00 +02:00
|
|
|
return true;
|
|
|
|
|
2009-02-23 21:22:15 +01:00
|
|
|
if (info.prereq && info.prereq->zero())
|
2004-05-04 23:01:00 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
ValueToString(Result value, int precision, bool compat)
|
|
|
|
{
|
|
|
|
stringstream val;
|
|
|
|
|
|
|
|
if (!isnan(value)) {
|
|
|
|
if (precision != -1)
|
|
|
|
val.precision(precision);
|
|
|
|
else if (value == rint(value))
|
|
|
|
val.precision(0);
|
|
|
|
|
|
|
|
val.unsetf(ios::showpoint);
|
|
|
|
val.setf(ios::fixed);
|
|
|
|
val << value;
|
|
|
|
} else {
|
|
|
|
val << (compat ? "<err: div-0>" : "no value");
|
|
|
|
}
|
|
|
|
|
|
|
|
return val.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ScalarPrint
|
|
|
|
{
|
|
|
|
Result value;
|
|
|
|
string name;
|
|
|
|
string desc;
|
|
|
|
StatFlags flags;
|
|
|
|
bool compat;
|
|
|
|
bool descriptions;
|
|
|
|
int precision;
|
|
|
|
Result pdf;
|
|
|
|
Result cdf;
|
|
|
|
|
|
|
|
void operator()(ostream &stream) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
ScalarPrint::operator()(ostream &stream) const
|
|
|
|
{
|
2008-09-28 06:03:49 +02:00
|
|
|
if ((flags & nozero && value == 0.0) ||
|
|
|
|
(flags & nonan && isnan(value)))
|
2004-05-04 23:01:00 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
stringstream pdfstr, cdfstr;
|
|
|
|
|
|
|
|
if (!isnan(pdf))
|
|
|
|
ccprintf(pdfstr, "%.2f%%", pdf * 100.0);
|
|
|
|
|
|
|
|
if (!isnan(cdf))
|
|
|
|
ccprintf(cdfstr, "%.2f%%", cdf * 100.0);
|
|
|
|
|
|
|
|
if (compat && flags & __substat) {
|
|
|
|
ccprintf(stream, "%32s %12s %10s %10s", name,
|
|
|
|
ValueToString(value, precision, compat), pdfstr, cdfstr);
|
|
|
|
} else {
|
|
|
|
ccprintf(stream, "%-40s %12s %10s %10s", name,
|
|
|
|
ValueToString(value, precision, compat), pdfstr, cdfstr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (descriptions) {
|
|
|
|
if (!desc.empty())
|
|
|
|
ccprintf(stream, " # %s", desc);
|
|
|
|
}
|
|
|
|
stream << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct VectorPrint
|
|
|
|
{
|
|
|
|
string name;
|
|
|
|
string desc;
|
|
|
|
vector<string> subnames;
|
|
|
|
vector<string> subdescs;
|
|
|
|
StatFlags flags;
|
|
|
|
bool compat;
|
|
|
|
bool descriptions;
|
|
|
|
int precision;
|
|
|
|
VResult vec;
|
|
|
|
Result total;
|
|
|
|
|
|
|
|
void operator()(ostream &stream) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
VectorPrint::operator()(std::ostream &stream) const
|
|
|
|
{
|
2008-10-09 13:58:23 +02:00
|
|
|
size_type _size = vec.size();
|
2004-05-04 23:01:00 +02:00
|
|
|
Result _total = 0.0;
|
|
|
|
|
|
|
|
if (flags & (pdf | cdf)) {
|
2008-10-09 13:58:23 +02:00
|
|
|
for (off_type i = 0; i < _size; ++i) {
|
2004-05-04 23:01:00 +02:00
|
|
|
_total += vec[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string base = name + (compat ? "_" : "::");
|
|
|
|
|
|
|
|
ScalarPrint print;
|
|
|
|
print.name = name;
|
|
|
|
print.desc = desc;
|
2007-03-12 19:13:52 +01:00
|
|
|
print.compat = compat;
|
2004-05-04 23:01:00 +02:00
|
|
|
print.precision = precision;
|
|
|
|
print.descriptions = descriptions;
|
|
|
|
print.flags = flags;
|
|
|
|
print.pdf = NAN;
|
|
|
|
print.cdf = NAN;
|
|
|
|
|
|
|
|
bool havesub = !subnames.empty();
|
|
|
|
|
|
|
|
if (_size == 1) {
|
|
|
|
print.value = vec[0];
|
|
|
|
print(stream);
|
|
|
|
} else if (!compat) {
|
2008-10-09 13:58:23 +02:00
|
|
|
for (off_type i = 0; i < _size; ++i) {
|
2004-05-04 23:01:00 +02:00
|
|
|
if (havesub && (i >= subnames.size() || subnames[i].empty()))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
print.name = base + (havesub ? subnames[i] : to_string(i));
|
|
|
|
print.desc = subdescs.empty() ? desc : subdescs[i];
|
|
|
|
print.value = vec[i];
|
|
|
|
|
|
|
|
if (_total && (flags & pdf)) {
|
|
|
|
print.pdf = vec[i] / _total;
|
|
|
|
print.cdf += print.pdf;
|
|
|
|
}
|
|
|
|
|
|
|
|
print(stream);
|
|
|
|
}
|
|
|
|
|
2004-05-21 19:39:20 +02:00
|
|
|
if (flags & ::Stats::total) {
|
2004-05-04 23:01:00 +02:00
|
|
|
print.name = base + "total";
|
|
|
|
print.desc = desc;
|
|
|
|
print.value = total;
|
|
|
|
print(stream);
|
|
|
|
}
|
|
|
|
} else {
|
2004-05-21 19:39:20 +02:00
|
|
|
if (flags & ::Stats::total) {
|
2004-05-04 23:01:00 +02:00
|
|
|
print.value = total;
|
|
|
|
print(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
Result _pdf = 0.0;
|
|
|
|
Result _cdf = 0.0;
|
|
|
|
if (flags & dist) {
|
|
|
|
ccprintf(stream, "%s.start_dist\n", name);
|
2008-10-09 13:58:23 +02:00
|
|
|
for (off_type i = 0; i < _size; ++i) {
|
2004-05-04 23:01:00 +02:00
|
|
|
print.name = havesub ? subnames[i] : to_string(i);
|
|
|
|
print.desc = subdescs.empty() ? desc : subdescs[i];
|
|
|
|
print.flags |= __substat;
|
|
|
|
print.value = vec[i];
|
|
|
|
|
|
|
|
if (_total) {
|
|
|
|
_pdf = vec[i] / _total;
|
|
|
|
_cdf += _pdf;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & pdf)
|
|
|
|
print.pdf = _pdf;
|
|
|
|
if (flags & cdf)
|
|
|
|
print.cdf = _cdf;
|
|
|
|
|
|
|
|
print(stream);
|
|
|
|
}
|
|
|
|
ccprintf(stream, "%s.end_dist\n", name);
|
|
|
|
} else {
|
2008-10-09 13:58:23 +02:00
|
|
|
for (off_type i = 0; i < _size; ++i) {
|
2004-05-04 23:01:00 +02:00
|
|
|
if (havesub && subnames[i].empty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
print.name = base;
|
|
|
|
print.name += havesub ? subnames[i] : to_string(i);
|
|
|
|
print.desc = subdescs.empty() ? desc : subdescs[i];
|
|
|
|
print.value = vec[i];
|
|
|
|
|
|
|
|
if (_total) {
|
|
|
|
_pdf = vec[i] / _total;
|
|
|
|
_cdf += _pdf;
|
|
|
|
} else {
|
|
|
|
_pdf = _cdf = NAN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & pdf) {
|
|
|
|
print.pdf = _pdf;
|
|
|
|
print.cdf = _cdf;
|
|
|
|
}
|
|
|
|
|
|
|
|
print(stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct DistPrint
|
|
|
|
{
|
|
|
|
string name;
|
|
|
|
string desc;
|
|
|
|
StatFlags flags;
|
|
|
|
bool compat;
|
|
|
|
bool descriptions;
|
|
|
|
int precision;
|
|
|
|
|
|
|
|
Counter min;
|
|
|
|
Counter max;
|
|
|
|
Counter bucket_size;
|
2008-10-09 13:58:23 +02:00
|
|
|
size_type size;
|
2004-05-04 23:01:00 +02:00
|
|
|
bool fancy;
|
|
|
|
|
2009-03-07 23:30:53 +01:00
|
|
|
const DistData &data;
|
|
|
|
|
|
|
|
DistPrint(const DistInfoBase &info);
|
|
|
|
DistPrint(const VectorDistInfoBase &info, int i);
|
|
|
|
void init(const Info &info, const DistParams *params);
|
2004-05-04 23:01:00 +02:00
|
|
|
void operator()(ostream &stream) const;
|
|
|
|
};
|
|
|
|
|
2009-03-07 23:30:53 +01:00
|
|
|
DistPrint::DistPrint(const DistInfoBase &info)
|
|
|
|
: data(info.data)
|
|
|
|
{
|
|
|
|
init(info, safe_cast<const DistParams *>(info.storageParams));
|
|
|
|
}
|
|
|
|
|
|
|
|
DistPrint::DistPrint(const VectorDistInfoBase &info, int i)
|
|
|
|
: data(info.data[i])
|
|
|
|
{
|
|
|
|
init(info, safe_cast<const DistParams *>(info.storageParams));
|
|
|
|
|
|
|
|
name = info.name + "_" +
|
|
|
|
(info.subnames[i].empty() ? (to_string(i)) : info.subnames[i]);
|
|
|
|
|
|
|
|
if (!info.subdescs[i].empty())
|
|
|
|
desc = info.subdescs[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DistPrint::init(const Info &info, const DistParams *params)
|
|
|
|
{
|
|
|
|
name = info.name;
|
|
|
|
desc = info.desc;
|
|
|
|
flags = info.flags;
|
|
|
|
compat = compat;
|
|
|
|
descriptions = descriptions;
|
|
|
|
precision = info.precision;
|
|
|
|
|
|
|
|
fancy = params->fancy;
|
|
|
|
min = params->min;
|
|
|
|
max = params->max;
|
|
|
|
bucket_size = params->bucket_size;
|
|
|
|
size = params->buckets;
|
|
|
|
}
|
|
|
|
|
2004-05-04 23:01:00 +02:00
|
|
|
void
|
|
|
|
DistPrint::operator()(ostream &stream) const
|
|
|
|
{
|
2009-03-07 23:30:53 +01:00
|
|
|
Result stdev = NAN;
|
|
|
|
if (data.samples)
|
|
|
|
stdev = sqrt((data.samples * data.squares - data.sum * data.sum) /
|
|
|
|
(data.samples * (data.samples - 1.0)));
|
|
|
|
|
2004-05-04 23:01:00 +02:00
|
|
|
if (fancy) {
|
|
|
|
ScalarPrint print;
|
|
|
|
string base = name + (compat ? "_" : "::");
|
|
|
|
|
|
|
|
print.precision = precision;
|
|
|
|
print.flags = flags;
|
|
|
|
print.compat = compat;
|
|
|
|
print.descriptions = descriptions;
|
|
|
|
print.desc = desc;
|
|
|
|
print.pdf = NAN;
|
|
|
|
print.cdf = NAN;
|
|
|
|
|
|
|
|
print.name = base + "mean";
|
2009-03-07 23:30:53 +01:00
|
|
|
print.value = data.samples ? data.sum / data.samples : NAN;
|
2004-05-04 23:01:00 +02:00
|
|
|
print(stream);
|
|
|
|
|
|
|
|
print.name = base + "stdev";
|
2009-03-07 23:30:53 +01:00
|
|
|
print.value = stdev;
|
2004-05-04 23:01:00 +02:00
|
|
|
print(stream);
|
|
|
|
|
|
|
|
print.name = "**Ignore: " + base + "TOT";
|
2009-03-07 23:30:53 +01:00
|
|
|
print.value = data.samples;
|
2004-05-04 23:01:00 +02:00
|
|
|
print(stream);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-03-07 23:30:53 +01:00
|
|
|
assert(size == data.cvec.size());
|
2004-05-04 23:01:00 +02:00
|
|
|
|
|
|
|
Result total = 0.0;
|
|
|
|
|
2009-03-07 23:30:53 +01:00
|
|
|
total += data.underflow;
|
2008-10-09 13:58:23 +02:00
|
|
|
for (off_type i = 0; i < size; ++i)
|
2009-03-07 23:30:53 +01:00
|
|
|
total += data.cvec[i];
|
|
|
|
total += data.overflow;
|
2004-05-04 23:01:00 +02:00
|
|
|
|
|
|
|
string base = name + (compat ? "." : "::");
|
|
|
|
|
|
|
|
ScalarPrint print;
|
|
|
|
print.desc = compat ? "" : desc;
|
|
|
|
print.flags = flags;
|
|
|
|
print.compat = compat;
|
|
|
|
print.descriptions = descriptions;
|
|
|
|
print.precision = precision;
|
|
|
|
print.pdf = NAN;
|
|
|
|
print.cdf = NAN;
|
|
|
|
|
|
|
|
if (compat) {
|
|
|
|
ccprintf(stream, "%-42s", base + "start_dist");
|
|
|
|
if (descriptions && !desc.empty())
|
|
|
|
ccprintf(stream, " # %s", desc);
|
|
|
|
stream << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
print.name = base + "samples";
|
2009-03-07 23:30:53 +01:00
|
|
|
print.value = data.samples;
|
2004-05-04 23:01:00 +02:00
|
|
|
print(stream);
|
|
|
|
|
|
|
|
print.name = base + "min_value";
|
2009-03-07 23:30:53 +01:00
|
|
|
print.value = data.min_val;
|
2004-05-04 23:01:00 +02:00
|
|
|
print(stream);
|
|
|
|
|
2009-03-07 23:30:53 +01:00
|
|
|
if (!compat || data.underflow > 0.0) {
|
2004-05-04 23:01:00 +02:00
|
|
|
print.name = base + "underflows";
|
2009-03-07 23:30:53 +01:00
|
|
|
print.value = data.underflow;
|
2004-05-04 23:01:00 +02:00
|
|
|
if (!compat && total) {
|
2009-03-07 23:30:53 +01:00
|
|
|
print.pdf = data.underflow / total;
|
2004-05-04 23:01:00 +02:00
|
|
|
print.cdf += print.pdf;
|
|
|
|
}
|
|
|
|
print(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!compat) {
|
2008-10-09 13:58:23 +02:00
|
|
|
for (off_type i = 0; i < size; ++i) {
|
2004-05-04 23:01:00 +02:00
|
|
|
stringstream namestr;
|
2009-02-23 21:04:50 +01:00
|
|
|
namestr << base;
|
2004-05-04 23:01:00 +02:00
|
|
|
|
|
|
|
Counter low = i * bucket_size + min;
|
|
|
|
Counter high = ::min(low + bucket_size, max);
|
|
|
|
namestr << low;
|
|
|
|
if (low < high)
|
|
|
|
namestr << "-" << high;
|
|
|
|
|
|
|
|
print.name = namestr.str();
|
2009-03-07 23:30:53 +01:00
|
|
|
print.value = data.cvec[i];
|
2004-05-04 23:01:00 +02:00
|
|
|
if (total) {
|
2009-03-07 23:30:53 +01:00
|
|
|
print.pdf = data.cvec[i] / total;
|
2004-05-04 23:01:00 +02:00
|
|
|
print.cdf += print.pdf;
|
|
|
|
}
|
|
|
|
print(stream);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Counter _min;
|
|
|
|
Result _pdf;
|
|
|
|
Result _cdf = 0.0;
|
|
|
|
|
|
|
|
print.flags = flags | __substat;
|
|
|
|
|
2008-10-09 13:58:23 +02:00
|
|
|
for (off_type i = 0; i < size; ++i) {
|
2009-03-07 23:30:53 +01:00
|
|
|
if ((flags & nozero && data.cvec[i] == 0.0) ||
|
|
|
|
(flags & nonan && isnan(data.cvec[i])))
|
2004-05-04 23:01:00 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
_min = i * bucket_size + min;
|
2009-03-07 23:30:53 +01:00
|
|
|
_pdf = data.cvec[i] / total * 100.0;
|
2004-05-04 23:01:00 +02:00
|
|
|
_cdf += _pdf;
|
|
|
|
|
|
|
|
|
|
|
|
print.name = ValueToString(_min, 0, compat);
|
2009-03-07 23:30:53 +01:00
|
|
|
print.value = data.cvec[i];
|
2004-05-04 23:01:00 +02:00
|
|
|
print.pdf = (flags & pdf) ? _pdf : NAN;
|
|
|
|
print.cdf = (flags & cdf) ? _cdf : NAN;
|
|
|
|
print(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
print.flags = flags;
|
|
|
|
}
|
|
|
|
|
2009-03-07 23:30:53 +01:00
|
|
|
if (!compat || data.overflow > 0.0) {
|
2004-05-04 23:01:00 +02:00
|
|
|
print.name = base + "overflows";
|
2009-03-07 23:30:53 +01:00
|
|
|
print.value = data.overflow;
|
2004-05-04 23:01:00 +02:00
|
|
|
if (!compat && total) {
|
2009-03-07 23:30:53 +01:00
|
|
|
print.pdf = data.overflow / total;
|
2004-05-04 23:01:00 +02:00
|
|
|
print.cdf += print.pdf;
|
|
|
|
} else {
|
|
|
|
print.pdf = NAN;
|
|
|
|
print.cdf = NAN;
|
|
|
|
}
|
|
|
|
print(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
print.pdf = NAN;
|
|
|
|
print.cdf = NAN;
|
|
|
|
|
|
|
|
if (!compat) {
|
|
|
|
print.name = base + "total";
|
|
|
|
print.value = total;
|
|
|
|
print(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
print.name = base + "max_value";
|
2009-03-07 23:30:53 +01:00
|
|
|
print.value = data.max_val;
|
2004-05-04 23:01:00 +02:00
|
|
|
print(stream);
|
|
|
|
|
2009-03-07 23:30:53 +01:00
|
|
|
if (!compat && data.samples != 0) {
|
2004-05-04 23:01:00 +02:00
|
|
|
print.name = base + "mean";
|
2009-03-07 23:30:53 +01:00
|
|
|
print.value = data.sum / data.samples;
|
2004-05-04 23:01:00 +02:00
|
|
|
print(stream);
|
|
|
|
|
|
|
|
print.name = base + "stdev";
|
2009-03-07 23:30:53 +01:00
|
|
|
print.value = stdev;
|
2004-05-04 23:01:00 +02:00
|
|
|
print(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (compat)
|
|
|
|
ccprintf(stream, "%send_dist\n\n", base);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-02-23 21:22:15 +01:00
|
|
|
Text::visit(const ScalarInfoBase &info)
|
2004-05-04 23:01:00 +02:00
|
|
|
{
|
2009-02-23 21:22:15 +01:00
|
|
|
if (noOutput(info))
|
2004-05-04 23:01:00 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
ScalarPrint print;
|
2009-02-23 21:22:15 +01:00
|
|
|
print.value = info.result();
|
|
|
|
print.name = info.name;
|
|
|
|
print.desc = info.desc;
|
|
|
|
print.flags = info.flags;
|
2004-05-04 23:01:00 +02:00
|
|
|
print.compat = compat;
|
|
|
|
print.descriptions = descriptions;
|
2009-02-23 21:22:15 +01:00
|
|
|
print.precision = info.precision;
|
2004-05-04 23:01:00 +02:00
|
|
|
print.pdf = NAN;
|
|
|
|
print.cdf = NAN;
|
|
|
|
|
|
|
|
print(*stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-02-23 21:22:15 +01:00
|
|
|
Text::visit(const VectorInfoBase &info)
|
2004-05-04 23:01:00 +02:00
|
|
|
{
|
2009-02-23 21:22:15 +01:00
|
|
|
if (noOutput(info))
|
2004-05-04 23:01:00 +02:00
|
|
|
return;
|
|
|
|
|
2009-02-23 21:22:15 +01:00
|
|
|
size_type size = info.size();
|
2004-05-04 23:01:00 +02:00
|
|
|
VectorPrint print;
|
|
|
|
|
2009-02-23 21:22:15 +01:00
|
|
|
print.name = info.name;
|
|
|
|
print.desc = info.desc;
|
|
|
|
print.flags = info.flags;
|
2004-05-04 23:01:00 +02:00
|
|
|
print.compat = compat;
|
|
|
|
print.descriptions = descriptions;
|
2009-02-23 21:22:15 +01:00
|
|
|
print.precision = info.precision;
|
|
|
|
print.vec = info.result();
|
|
|
|
print.total = info.total();
|
2004-05-04 23:01:00 +02:00
|
|
|
|
2009-02-23 21:22:15 +01:00
|
|
|
if (!info.subnames.empty()) {
|
2008-10-09 13:58:23 +02:00
|
|
|
for (off_type i = 0; i < size; ++i) {
|
2009-02-23 21:22:15 +01:00
|
|
|
if (!info.subnames[i].empty()) {
|
|
|
|
print.subnames = info.subnames;
|
2004-05-04 23:01:00 +02:00
|
|
|
print.subnames.resize(size);
|
2008-10-09 13:58:23 +02:00
|
|
|
for (off_type i = 0; i < size; ++i) {
|
2009-02-23 21:22:15 +01:00
|
|
|
if (!info.subnames[i].empty() &&
|
|
|
|
!info.subdescs[i].empty()) {
|
|
|
|
print.subdescs = info.subdescs;
|
2004-05-04 23:01:00 +02:00
|
|
|
print.subdescs.resize(size);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print(*stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-02-23 21:22:15 +01:00
|
|
|
Text::visit(const Vector2dInfoBase &info)
|
2004-05-04 23:01:00 +02:00
|
|
|
{
|
2009-02-23 21:22:15 +01:00
|
|
|
if (noOutput(info))
|
2004-05-04 23:01:00 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
bool havesub = false;
|
|
|
|
VectorPrint print;
|
|
|
|
|
2009-02-23 21:22:15 +01:00
|
|
|
print.subnames = info.y_subnames;
|
|
|
|
print.flags = info.flags;
|
2004-05-04 23:01:00 +02:00
|
|
|
print.compat = compat;
|
|
|
|
print.descriptions = descriptions;
|
2009-02-23 21:22:15 +01:00
|
|
|
print.precision = info.precision;
|
2004-05-04 23:01:00 +02:00
|
|
|
|
2009-02-23 21:22:15 +01:00
|
|
|
if (!info.subnames.empty()) {
|
|
|
|
for (off_type i = 0; i < info.x; ++i)
|
|
|
|
if (!info.subnames[i].empty())
|
2004-05-04 23:01:00 +02:00
|
|
|
havesub = true;
|
|
|
|
}
|
|
|
|
|
2009-02-23 21:22:15 +01:00
|
|
|
VResult tot_vec(info.y);
|
2004-05-04 23:01:00 +02:00
|
|
|
Result super_total = 0.0;
|
2009-02-23 21:22:15 +01:00
|
|
|
for (off_type i = 0; i < info.x; ++i) {
|
|
|
|
if (havesub && (i >= info.subnames.size() || info.subnames[i].empty()))
|
2004-05-04 23:01:00 +02:00
|
|
|
continue;
|
|
|
|
|
2009-02-23 21:22:15 +01:00
|
|
|
off_type iy = i * info.y;
|
|
|
|
VResult yvec(info.y);
|
2004-05-04 23:01:00 +02:00
|
|
|
|
|
|
|
Result total = 0.0;
|
2009-02-23 21:22:15 +01:00
|
|
|
for (off_type j = 0; j < info.y; ++j) {
|
|
|
|
yvec[j] = info.cvec[iy + j];
|
2004-05-04 23:01:00 +02:00
|
|
|
tot_vec[j] += yvec[j];
|
|
|
|
total += yvec[j];
|
|
|
|
super_total += yvec[j];
|
|
|
|
}
|
|
|
|
|
2009-02-23 21:22:15 +01:00
|
|
|
print.name = info.name + "_" +
|
|
|
|
(havesub ? info.subnames[i] : to_string(i));
|
|
|
|
print.desc = info.desc;
|
2004-05-04 23:01:00 +02:00
|
|
|
print.vec = yvec;
|
|
|
|
print.total = total;
|
|
|
|
print(*stream);
|
|
|
|
}
|
|
|
|
|
2009-02-23 21:22:15 +01:00
|
|
|
if ((info.flags & ::Stats::total) && (info.x > 1)) {
|
|
|
|
print.name = info.name;
|
|
|
|
print.desc = info.desc;
|
2004-05-04 23:01:00 +02:00
|
|
|
print.vec = tot_vec;
|
|
|
|
print.total = super_total;
|
|
|
|
print(*stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-02-23 21:22:15 +01:00
|
|
|
Text::visit(const DistInfoBase &info)
|
2004-05-04 23:01:00 +02:00
|
|
|
{
|
2009-02-23 21:22:15 +01:00
|
|
|
if (noOutput(info))
|
2004-05-04 23:01:00 +02:00
|
|
|
return;
|
|
|
|
|
2009-03-07 23:30:53 +01:00
|
|
|
DistPrint print(info);
|
2004-05-04 23:01:00 +02:00
|
|
|
print(*stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-02-23 21:22:15 +01:00
|
|
|
Text::visit(const VectorDistInfoBase &info)
|
2004-05-04 23:01:00 +02:00
|
|
|
{
|
2009-02-23 21:22:15 +01:00
|
|
|
if (noOutput(info))
|
2004-05-04 23:01:00 +02:00
|
|
|
return;
|
|
|
|
|
2009-02-23 21:22:15 +01:00
|
|
|
for (off_type i = 0; i < info.size(); ++i) {
|
2009-03-07 23:30:53 +01:00
|
|
|
DistPrint print(info, i);
|
2004-05-04 23:01:00 +02:00
|
|
|
print(*stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-02-23 21:22:15 +01:00
|
|
|
Text::visit(const FormulaInfoBase &info)
|
2004-05-04 23:01:00 +02:00
|
|
|
{
|
2009-02-23 21:22:15 +01:00
|
|
|
visit((const VectorInfoBase &)info);
|
2004-05-04 23:01:00 +02:00
|
|
|
}
|
|
|
|
|
2007-02-18 07:52:32 +01:00
|
|
|
bool
|
|
|
|
initText(const string &filename, bool desc, bool compat)
|
|
|
|
{
|
|
|
|
static Text text;
|
|
|
|
static bool connected = false;
|
|
|
|
|
|
|
|
if (connected)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
extern list<Output *> OutputList;
|
|
|
|
|
|
|
|
text.open(*simout.find(filename));
|
|
|
|
text.descriptions = desc;
|
|
|
|
text.compat = compat;
|
|
|
|
OutputList.push_back(&text);
|
|
|
|
connected = true;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-05-21 19:39:20 +02:00
|
|
|
/* namespace Stats */ }
|