base-stats,misc: Rename Stats namespace as statistics

As part of recent decisions regarding namespace
naming conventions, all namespaces will be changed
to snake case.

::Stats became ::statistics.

"statistics" was chosen over "stats" to avoid generating
conflicts with the already existing variables (there are
way too many "stats" in the codebase), which would make
this patch even more disturbing for the users.

Change-Id: If877b12d7dac356f86e3b3d941bf7558a4fd8719
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45421
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Daniel R. Carvalho
2021-05-06 20:00:51 -03:00
committed by Daniel Carvalho
parent fa505f1c23
commit 98ac080ec4
228 changed files with 3078 additions and 2970 deletions

View File

@@ -50,7 +50,9 @@
#include "base/logging.hh"
#include "sim/root.hh"
namespace Stats {
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
// We wrap these in a function to make sure they're built in time.
std::list<Info *> &
@@ -292,7 +294,7 @@ dump()
if (dumpHandler)
dumpHandler();
else
fatal("No registered Stats::dump handler");
fatal("No registered statistics::dump handler");
}
void
@@ -301,7 +303,7 @@ reset()
if (resetHandler)
resetHandler();
else
fatal("No registered Stats::reset handler");
fatal("No registered statistics::reset handler");
}
const Info *
@@ -321,10 +323,10 @@ registerDumpCallback(const std::function<void()> &callback)
dumpQueue.push_back(callback);
}
} // namespace Stats
} // namespace statistics
void
debugDumpStats()
{
Stats::dump();
statistics::dump();
}

View File

@@ -87,7 +87,9 @@
#include "base/types.hh"
/* A namespace for all of the Statistics */
namespace Stats {
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
template <class Stat, class Base>
class InfoProxy : public Base
@@ -262,9 +264,9 @@ class DataWrap : public InfoAccess
if (desc)
info->desc = desc;
// Stat that does not belong to any Stats::Group is a legacy stat
// Stat that does not belong to any statistics::Group is a legacy stat
std::string common_message = "Legacy stat is a stat that does not "
"belong to any Stats::Group. Legacy stat is deprecated.";
"belong to any statistics::Group. Legacy stat is deprecated.";
if (parent == nullptr && name != nullptr)
warn(csprintf("`%s` is a legacy stat. %s", name, common_message));
else if (parent == nullptr)
@@ -2936,7 +2938,7 @@ std::list<Info *> &statsList();
typedef std::map<const void *, Info *> MapType;
MapType &statsMap();
} // namespace Stats
} // namespace statistics
void debugDumpStats();

View File

@@ -44,7 +44,9 @@
#include "debug/Stats.hh"
#include "sim/sim_object.hh"
namespace Stats {
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
Group::Group(Group *parent, const char *name)
: mergedParent(nullptr)
@@ -102,7 +104,7 @@ Group::preDumpStats()
}
void
Group::addStat(Stats::Info *info)
Group::addStat(statistics::Info *info)
{
stats.push_back(info);
if (mergedParent)
@@ -183,4 +185,4 @@ Group::getStats() const
return stats;
}
} // namespace Stats
} // namespace statistics

View File

@@ -42,25 +42,26 @@
#include <string>
#include <vector>
#include "base/compiler.hh"
#include "base/stats/units.hh"
/**
* Convenience macro to add a stat to a statistics group.
*
* This macro is used to add a stat to a Stats::Group in the
* This macro is used to add a stat to a statistics::Group in the
* initilization list in the Group's constructor. The macro
* automatically assigns the stat to the current group and gives it
* the same name as in the class. For example:
*
* \code
* struct MyStats : public Stats::Group
* struct MyStats : public statistics::Group
* {
* Stats::Scalar scalar0;
* Stats::Scalar scalar1;
* statistics::Scalar scalar0;
* statistics::Scalar scalar1;
*
* Group()
* : ADD_STAT(scalar0, "Description of scalar0"),
* scalar1(this, "scalar1", Stats::units::Unspecified::get(),
* scalar1(this, "scalar1", statistics::units::Unspecified::get(),
* "Description of scalar1")
* {
* }
@@ -70,7 +71,9 @@
#define ADD_STAT(n, ...) n(this, #n, __VA_ARGS__)
namespace Stats {
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
class Info;
@@ -155,7 +158,7 @@ class Group
*
* @ingroup api_stats
*/
void addStat(Stats::Info *info);
void addStat(statistics::Info *info);
/**
* Get all child groups associated with this object.
@@ -215,6 +218,6 @@ class Group
std::vector<Info *> stats;
};
} // namespace Stats
} // namespace statistics
#endif // __BASE_STATS_GROUP_HH__

View File

@@ -54,7 +54,9 @@ bool emptyStrings(const T &labels)
}
namespace Stats {
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
Hdf5::Hdf5(const std::string &file, unsigned chunking,
bool desc, bool formulas)
@@ -320,4 +322,4 @@ initHDF5(const std::string &filename, unsigned chunking,
new Hdf5(simout.resolve(filename), chunking, desc, formulas));
}
}; // namespace Stats
}; // namespace statistics

View File

@@ -45,11 +45,14 @@
#include <string>
#include <vector>
#include "base/compiler.hh"
#include "base/output.hh"
#include "base/stats/output.hh"
#include "base/stats/types.hh"
namespace Stats {
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
class Hdf5 : public Output
{
@@ -152,6 +155,6 @@ std::unique_ptr<Output> initHDF5(
const std::string &filename,unsigned chunking = 10,
bool desc = true, bool formulas = true);
} // namespace Stats
} // namespace statistics
#endif // __BASE_STATS_HDF5_HH__

View File

@@ -50,7 +50,9 @@
#include "base/logging.hh"
#include "base/str.hh"
namespace Stats {
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
std::string Info::separatorString = "::";
@@ -164,7 +166,7 @@ Info::less(Info *stat1, Info *stat2)
bool
Info::baseCheck() const
{
if (!(flags & Stats::init)) {
if (!(flags & statistics::init)) {
#ifdef DEBUG
cprintf("this is stat number %d\n", id);
#endif
@@ -219,4 +221,4 @@ Vector2dInfo::enable()
y_subnames.resize(y);
}
} // namespace Stats
} // namespace statistics

View File

@@ -29,11 +29,14 @@
#ifndef __BASE_STATS_INFO_HH__
#define __BASE_STATS_INFO_HH__
#include "base/compiler.hh"
#include "base/flags.hh"
#include "base/stats/types.hh"
#include "base/stats/units.hh"
namespace Stats {
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
class Group;
@@ -261,6 +264,6 @@ class SparseHistInfo : public Info
typedef std::map<std::string, Info *> NameMapType;
NameMapType &nameMap();
} // namespace Stats
} // namespace statistics
#endif // __BASE_STATS_INFO_HH__

View File

@@ -44,7 +44,11 @@
#include <list>
#include <string>
namespace Stats {
#include "base/compiler.hh"
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
class Info;
class ScalarInfo;
@@ -75,6 +79,6 @@ struct Output
virtual void visit(const SparseHistInfo &info) = 0; // Sparse histogram
};
} // namespace Stats
} // namespace statistics
#endif // __BASE_STATS_OUTPUT_HH__

View File

@@ -43,7 +43,9 @@
#include <cmath>
namespace Stats {
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
void
DistStor::sample(Counter val, int number)
@@ -222,4 +224,4 @@ HistStor::add(HistStor *hs)
cvec[i] += hs->cvec[i];
}
} // namespace Stats
} // namespace statistics

View File

@@ -34,13 +34,16 @@
#include <cmath>
#include "base/cast.hh"
#include "base/compiler.hh"
#include "base/logging.hh"
#include "base/stats/info.hh"
#include "base/stats/types.hh"
// For curTick().
#include "sim/core.hh"
namespace Stats {
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
struct StorageParams
{
@@ -778,6 +781,6 @@ class SparseHistStor
}
};
} // namespace Stats
} // namespace statistics
#endif // __BASE_STATS_STORAGE_HH__

View File

@@ -44,10 +44,10 @@ void increaseTick() { tickHandler.setCurTick(curTick() + 1); }
/** A pair of value and its number of samples, used for sampling. */
struct ValueSamples
{
Stats::Counter value;
Stats::Counter numSamples;
statistics::Counter value;
statistics::Counter numSamples;
ValueSamples(Stats::Counter value, Stats::Counter num_samples)
ValueSamples(statistics::Counter value, statistics::Counter num_samples)
: value(value), numSamples(num_samples)
{
}
@@ -58,11 +58,11 @@ struct ValueSamples
* @todo There is no real dependency on the info class, so this must be
* removed on a cleanup.
*/
class MockInfo : public Stats::Info
class MockInfo : public statistics::Info
{
public:
MockInfo(Stats::StorageParams* storage_params)
: Stats::Info()
MockInfo(statistics::StorageParams* storage_params)
: statistics::Info()
{
this->storageParams = storage_params;
}
@@ -72,45 +72,45 @@ class MockInfo : public Stats::Info
void prepare() override { }
void reset() override { }
bool zero() const override { return true; }
void visit(Stats::Output &visitor) override { }
void visit(statistics::Output &visitor) override { }
};
/** Test setting and getting a value to the storage. */
TEST(StatsStatStorTest, SetValueResult)
{
Stats::StatStor stor(nullptr);
Stats::Counter val;
statistics::StatStor stor(nullptr);
statistics::Counter val;
val = 10;
stor.set(val);
ASSERT_EQ(stor.value(), val);
ASSERT_EQ(stor.result(), Stats::Result(val));
ASSERT_EQ(stor.result(), statistics::Result(val));
val = 1234;
stor.set(val);
ASSERT_EQ(stor.value(), val);
ASSERT_EQ(stor.result(), Stats::Result(val));
ASSERT_EQ(stor.result(), statistics::Result(val));
}
/** Test if prepare does not change the value. */
TEST(StatsStatStorTest, Prepare)
{
Stats::StatStor stor(nullptr);
Stats::Counter val;
statistics::StatStor stor(nullptr);
statistics::Counter val;
val = 10;
stor.set(val);
stor.prepare(nullptr);
ASSERT_EQ(stor.value(), val);
ASSERT_EQ(stor.result(), Stats::Result(val));
ASSERT_EQ(stor.result(), statistics::Result(val));
}
/** Test whether incrementing and decrementing work as expected. */
TEST(StatsStatStorTest, IncDec)
{
Stats::StatStor stor(nullptr);
Stats::Counter diff_val = 10;
Stats::Counter val = 0;
statistics::StatStor stor(nullptr);
statistics::Counter diff_val = 10;
statistics::Counter val = 0;
stor.inc(diff_val);
val += diff_val;
@@ -136,8 +136,8 @@ TEST(StatsStatStorTest, IncDec)
*/
TEST(StatsStatStorTest, ZeroReset)
{
Stats::StatStor stor(nullptr);
Stats::Counter val = 10;
statistics::StatStor stor(nullptr);
statistics::Counter val = 10;
ASSERT_TRUE(stor.zero());
@@ -152,9 +152,9 @@ TEST(StatsStatStorTest, ZeroReset)
/** Test setting and getting a value to the storage. */
TEST(StatsAvgStorTest, SetValueResult)
{
Stats::AvgStor stor(nullptr);
Stats::Counter val;
Stats::Result total = 0;
statistics::AvgStor stor(nullptr);
statistics::Counter val;
statistics::Result total = 0;
Tick last_reset = 0;
Tick last_tick = 0;
@@ -162,8 +162,8 @@ TEST(StatsAvgStorTest, SetValueResult)
stor.set(val);
last_tick = curTick();
ASSERT_EQ(stor.value(), val);
ASSERT_EQ(stor.result(), Stats::Result(total + val) /
Stats::Result(curTick() - last_reset + 1));
ASSERT_EQ(stor.result(), statistics::Result(total + val) /
statistics::Result(curTick() - last_reset + 1));
increaseTick();
total += val * (curTick() - last_tick);
@@ -171,8 +171,8 @@ TEST(StatsAvgStorTest, SetValueResult)
stor.set(val);
last_tick = curTick();
ASSERT_EQ(stor.value(), val);
ASSERT_EQ(stor.result(), Stats::Result(total + val) /
Stats::Result(curTick() - last_reset + 1));
ASSERT_EQ(stor.result(), statistics::Result(total + val) /
statistics::Result(curTick() - last_reset + 1));
increaseTick();
}
@@ -182,7 +182,7 @@ TEST(StatsAvgStorTest, SetValueResult)
*/
TEST(StatsAvgStorDeathTest, Result)
{
Stats::AvgStor stor(nullptr);
statistics::AvgStor stor(nullptr);
increaseTick();
ASSERT_DEATH(stor.result(), ".+");
}
@@ -194,9 +194,9 @@ TEST(StatsAvgStorDeathTest, Result)
*/
TEST(StatsAvgStorTest, Prepare)
{
Stats::AvgStor stor(nullptr);
Stats::Counter val = 10;
Stats::Result total = 0;
statistics::AvgStor stor(nullptr);
statistics::Counter val = 10;
statistics::Result total = 0;
Tick last_reset = 0;
Tick last_tick = 0;
@@ -204,25 +204,25 @@ TEST(StatsAvgStorTest, Prepare)
stor.set(val);
last_tick = curTick();
ASSERT_EQ(stor.value(), val);
ASSERT_EQ(stor.result(), Stats::Result(total + val) /
Stats::Result(curTick() - last_reset + 1));
ASSERT_EQ(stor.result(), statistics::Result(total + val) /
statistics::Result(curTick() - last_reset + 1));
increaseTick();
total += val * (curTick() - last_tick);
stor.prepare(nullptr);
last_tick = curTick();
ASSERT_EQ(stor.value(), val);
ASSERT_EQ(stor.result(), Stats::Result(total + val) /
Stats::Result(curTick() - last_reset + 1));
ASSERT_EQ(stor.result(), statistics::Result(total + val) /
statistics::Result(curTick() - last_reset + 1));
increaseTick();
}
/** Test whether incrementing and decrementing work as expected. */
TEST(StatsAvgStorTest, IncDec)
{
Stats::AvgStor stor(nullptr);
Stats::Counter diff_val = 10;
Stats::Counter val = 0;
statistics::AvgStor stor(nullptr);
statistics::Counter diff_val = 10;
statistics::Counter val = 0;
stor.set(diff_val);
val += diff_val;
@@ -252,8 +252,8 @@ TEST(StatsAvgStorTest, IncDec)
*/
TEST(StatsAvgStorTest, ZeroReset)
{
Stats::AvgStor stor(nullptr);
Stats::Counter val = 10;
statistics::AvgStor stor(nullptr);
statistics::Counter val = 10;
ASSERT_TRUE(stor.zero());
@@ -273,7 +273,7 @@ TEST(StatsAvgStorTest, ZeroReset)
/** Test that an assertion is thrown when bucket size is 0. */
TEST(StatsDistStorDeathTest, BucketSize0)
{
EXPECT_ANY_THROW(Stats::DistStor::Params params(0, 5, 0));
EXPECT_ANY_THROW(statistics::DistStor::Params params(0, 5, 0));
}
#endif
@@ -284,11 +284,11 @@ TEST(StatsDistStorDeathTest, BucketSize0)
*/
TEST(StatsDistStorTest, ZeroReset)
{
Stats::DistStor::Params params(0, 99, 10);
statistics::DistStor::Params params(0, 99, 10);
MockInfo info(&params);
Stats::DistStor stor(&info);
Stats::Counter val = 10;
Stats::Counter num_samples = 5;
statistics::DistStor stor(&info);
statistics::Counter val = 10;
statistics::Counter num_samples = 5;
ASSERT_TRUE(stor.zero());
@@ -306,14 +306,14 @@ TEST(StatsDistStorTest, ZeroReset)
*/
TEST(StatsDistStorTest, Size)
{
Stats::Counter val = 10;
Stats::Counter num_samples = 5;
Stats::Counter size = 20;
Stats::DistData data;
statistics::Counter val = 10;
statistics::Counter num_samples = 5;
statistics::Counter size = 20;
statistics::DistData data;
Stats::DistStor::Params params(0, 19, 1);
statistics::DistStor::Params params(0, 19, 1);
MockInfo info(&params);
Stats::DistStor stor(&info);
statistics::DistStor stor(&info);
ASSERT_EQ(stor.size(), size);
stor.sample(val, num_samples);
@@ -334,8 +334,8 @@ TEST(StatsDistStorTest, Size)
* @param no_log Whether log should not be compared.
*/
void
checkExpectedDistData(const Stats::DistData& data,
const Stats::DistData& expected_data, bool no_log = true)
checkExpectedDistData(const statistics::DistData& data,
const statistics::DistData& expected_data, bool no_log = true)
{
ASSERT_EQ(data.type, expected_data.type);
ASSERT_EQ(data.min, expected_data.min);
@@ -366,14 +366,14 @@ checkExpectedDistData(const Stats::DistData& data,
* setup to the expected values: bucket_size, min, max_val, and cvec.
*/
void
prepareCheckDistStor(Stats::DistStor::Params& params, ValueSamples* values,
int num_values, Stats::DistData& expected_data)
prepareCheckDistStor(statistics::DistStor::Params& params,
ValueSamples* values, int num_values, statistics::DistData& expected_data)
{
MockInfo info(&params);
Stats::DistStor stor(&info);
statistics::DistStor stor(&info);
Stats::Counter val;
Stats::DistData data;
statistics::Counter val;
statistics::DistData data;
expected_data.min = params.min;
expected_data.max = params.max;
@@ -400,14 +400,14 @@ prepareCheckDistStor(Stats::DistStor::Params& params, ValueSamples* values,
/** Test setting and getting value from storage. */
TEST(StatsDistStorTest, SamplePrepareSingle)
{
Stats::DistStor::Params params(0, 99, 5);
statistics::DistStor::Params params(0, 99, 5);
ValueSamples values[] = {{10, 5}};
int num_values = sizeof(values) / sizeof(ValueSamples);
// Setup expected data
Stats::DistData expected_data;
expected_data.type = Stats::Dist;
statistics::DistData expected_data;
expected_data.type = statistics::Dist;
expected_data.bucket_size = params.bucket_size;
expected_data.underflow = 0;
expected_data.overflow = 0;
@@ -423,7 +423,7 @@ TEST(StatsDistStorTest, SamplePrepareSingle)
/** Test setting and getting value from storage with multiple values. */
TEST(StatsDistStorTest, SamplePrepareMultiple)
{
Stats::DistStor::Params params(0, 99, 5);
statistics::DistStor::Params params(0, 99, 5);
// There are 20 buckets: [0,5[, [5,10[, [10,15[, ..., [95,100[.
// We test that values that pass the maximum bucket value (1234, 12345678,
@@ -436,8 +436,8 @@ TEST(StatsDistStorTest, SamplePrepareMultiple)
int num_values = sizeof(values) / sizeof(ValueSamples);
// Setup variables that should always match params' values
Stats::DistData expected_data;
expected_data.type = Stats::Dist;
statistics::DistData expected_data;
expected_data.type = statistics::Dist;
expected_data.min_val = -10;
expected_data.max_val = 12345678;
expected_data.bucket_size = params.bucket_size;
@@ -460,9 +460,9 @@ TEST(StatsDistStorTest, SamplePrepareMultiple)
/** Test resetting storage. */
TEST(StatsDistStorTest, Reset)
{
Stats::DistStor::Params params(0, 99, 5);
statistics::DistStor::Params params(0, 99, 5);
MockInfo info(&params);
Stats::DistStor stor(&info);
statistics::DistStor stor(&info);
// Populate storage with random samples
ValueSamples values[] = {{10, 5}, {1234, 2}, {12345678, 99}, {-10, 4},
@@ -474,11 +474,11 @@ TEST(StatsDistStorTest, Reset)
// Reset storage, and make sure all data has been cleared
stor.reset(&info);
Stats::DistData data;
statistics::DistData data;
stor.prepare(&info, data);
Stats::DistData expected_data;
expected_data.type = Stats::Dist;
statistics::DistData expected_data;
expected_data.type = statistics::Dist;
expected_data.bucket_size = params.bucket_size;
expected_data.underflow = 0;
expected_data.overflow = 0;
@@ -499,13 +499,13 @@ TEST(StatsDistStorTest, Reset)
/** Test that an assertion is thrown when not enough buckets are provided. */
TEST(StatsHistStorDeathTest, NotEnoughBuckets0)
{
EXPECT_ANY_THROW(Stats::HistStor::Params params(0));
EXPECT_ANY_THROW(statistics::HistStor::Params params(0));
}
/** Test that an assertion is thrown when not enough buckets are provided. */
TEST(StatsHistStorDeathTest, NotEnoughBuckets1)
{
EXPECT_ANY_THROW(Stats::HistStor::Params params(1));
EXPECT_ANY_THROW(statistics::HistStor::Params params(1));
}
#endif
@@ -516,11 +516,11 @@ TEST(StatsHistStorDeathTest, NotEnoughBuckets1)
*/
TEST(StatsHistStorTest, ZeroReset)
{
Stats::HistStor::Params params(10);
statistics::HistStor::Params params(10);
MockInfo info(&params);
Stats::HistStor stor(&info);
Stats::Counter val = 10;
Stats::Counter num_samples = 5;
statistics::HistStor stor(&info);
statistics::Counter val = 10;
statistics::Counter num_samples = 5;
ASSERT_TRUE(stor.zero());
@@ -538,15 +538,15 @@ TEST(StatsHistStorTest, ZeroReset)
*/
TEST(StatsHistStorTest, Size)
{
Stats::Counter val = 10;
Stats::Counter num_samples = 5;
Stats::DistData data;
Stats::size_type sizes[] = {2, 10, 1234};
statistics::Counter val = 10;
statistics::Counter num_samples = 5;
statistics::DistData data;
statistics::size_type sizes[] = {2, 10, 1234};
for (int i = 0; i < (sizeof(sizes) / sizeof(Stats::size_type)); i++) {
Stats::HistStor::Params params(sizes[i]);
for (int i = 0; i < (sizeof(sizes) / sizeof(statistics::size_type)); i++) {
statistics::HistStor::Params params(sizes[i]);
MockInfo info(&params);
Stats::HistStor stor(&info);
statistics::HistStor stor(&info);
ASSERT_EQ(stor.size(), sizes[i]);
stor.sample(val, num_samples);
@@ -571,14 +571,14 @@ TEST(StatsHistStorTest, Size)
* setup to the expected values: bucket_size, min, max_val, and cvec.
*/
void
prepareCheckHistStor(Stats::HistStor::Params& params, ValueSamples* values,
int num_values, Stats::DistData& expected_data)
prepareCheckHistStor(statistics::HistStor::Params& params,
ValueSamples* values, int num_values, statistics::DistData& expected_data)
{
MockInfo info(&params);
Stats::HistStor stor(&info);
statistics::HistStor stor(&info);
Stats::Counter val;
Stats::DistData data;
statistics::Counter val;
statistics::DistData data;
bool no_log = false;
expected_data.min_val = expected_data.min;
@@ -614,15 +614,15 @@ prepareCheckHistStor(Stats::HistStor::Params& params, ValueSamples* values,
*/
TEST(StatsHistStorTest, SamplePrepareFit)
{
Stats::HistStor::Params params(4);
statistics::HistStor::Params params(4);
// Setup expected data for the hand-carved values given. The final buckets
// will be divided at:
// Bkt0=[0,1[ , Bkt1=[1,2[, Bkt2=[2,3[, Bkt3=[3,4[
ValueSamples values[] = {{0, 5}, {1, 2}, {2, 99}, {3, 4}};
const int num_values = sizeof(values) / sizeof(ValueSamples);
Stats::DistData expected_data;
expected_data.type = Stats::Hist;
statistics::DistData expected_data;
expected_data.type = statistics::Hist;
expected_data.bucket_size = 1;
expected_data.min = 0;
expected_data.max_val = 3;
@@ -642,7 +642,7 @@ TEST(StatsHistStorTest, SamplePrepareFit)
*/
TEST(StatsHistStorTest, SamplePrepareSingleGrowUp)
{
Stats::HistStor::Params params(4);
statistics::HistStor::Params params(4);
// Setup expected data for the hand-carved values given. Since there
// are four buckets, and the highest value is 4, the bucket size will
@@ -650,8 +650,8 @@ TEST(StatsHistStorTest, SamplePrepareSingleGrowUp)
// Bkt0=[0,2[ , Bkt1=[2,4[, Bkt2=[4,6[, Bkt3=[6,8[
ValueSamples values[] = {{0, 5}, {1, 2}, {2, 99}, {4, 4}};
const int num_values = sizeof(values) / sizeof(ValueSamples);
Stats::DistData expected_data;
expected_data.type = Stats::Hist;
statistics::DistData expected_data;
expected_data.type = statistics::Hist;
expected_data.bucket_size = 2;
expected_data.min = 0;
expected_data.max_val = 6;
@@ -671,7 +671,7 @@ TEST(StatsHistStorTest, SamplePrepareSingleGrowUp)
*/
TEST(StatsHistStorTest, SamplePrepareMultipleGrowUp)
{
Stats::HistStor::Params params(4);
statistics::HistStor::Params params(4);
// Setup expected data for the hand-carved values given. Since there
// are four buckets, and the highest value is 4, the bucket size will
@@ -679,8 +679,8 @@ TEST(StatsHistStorTest, SamplePrepareMultipleGrowUp)
// Bkt0=[0,8[ , Bkt1=[8,16[, Bkt2=[16,24[, Bkt3=[24,32[
ValueSamples values[] = {{0, 5}, {1, 2}, {2, 99}, {16, 4}};
const int num_values = sizeof(values) / sizeof(ValueSamples);
Stats::DistData expected_data;
expected_data.type = Stats::Hist;
statistics::DistData expected_data;
expected_data.type = statistics::Hist;
expected_data.bucket_size = 8;
expected_data.min = 0;
expected_data.max_val = 24;
@@ -701,7 +701,7 @@ TEST(StatsHistStorTest, SamplePrepareMultipleGrowUp)
*/
TEST(StatsHistStorTest, SamplePrepareGrowDownOddBuckets)
{
Stats::HistStor::Params params(5);
statistics::HistStor::Params params(5);
// Setup expected data for the hand-carved values given. Since there
// is a negative value, the min bucket will change, and the bucket size
@@ -710,8 +710,8 @@ TEST(StatsHistStorTest, SamplePrepareGrowDownOddBuckets)
ValueSamples values[] =
{{0, 5}, {1, 2}, {2, 99}, {3, 12}, {4, 33}, {-1, 4}};
const int num_values = sizeof(values) / sizeof(ValueSamples);
Stats::DistData expected_data;
expected_data.type = Stats::Hist;
statistics::DistData expected_data;
expected_data.type = statistics::Hist;
expected_data.bucket_size = 2;
expected_data.min = -4;
expected_data.max_val = 4;
@@ -733,7 +733,7 @@ TEST(StatsHistStorTest, SamplePrepareGrowDownOddBuckets)
*/
TEST(StatsHistStorTest, SamplePrepareGrowDownEvenBuckets)
{
Stats::HistStor::Params params(4);
statistics::HistStor::Params params(4);
// Setup expected data for the hand-carved values given. Since there
// is a negative value, the min bucket will change, and the bucket size
@@ -741,8 +741,8 @@ TEST(StatsHistStorTest, SamplePrepareGrowDownEvenBuckets)
// Bkt0=[-4,-2[ , Bkt1=[-2,0[, Bkt2=[0,2[, Bkt3=[2,4[
ValueSamples values[] = {{0, 5}, {1, 2}, {2, 99}, {-1, 4}};
const int num_values = sizeof(values) / sizeof(ValueSamples);
Stats::DistData expected_data;
expected_data.type = Stats::Hist;
statistics::DistData expected_data;
expected_data.type = statistics::Hist;
expected_data.bucket_size = 2;
expected_data.min = -4;
expected_data.max_val = 2;
@@ -763,7 +763,7 @@ TEST(StatsHistStorTest, SamplePrepareGrowDownEvenBuckets)
*/
TEST(StatsHistStorTest, SamplePrepareGrowDownGrowOutOddBuckets)
{
Stats::HistStor::Params params(5);
statistics::HistStor::Params params(5);
// Setup expected data for the hand-carved values given. Since there
// is a negative value, the min bucket will change, and the bucket size
@@ -772,8 +772,8 @@ TEST(StatsHistStorTest, SamplePrepareGrowDownGrowOutOddBuckets)
ValueSamples values[] =
{{0, 5}, {1, 2}, {2, 99}, {3, 12}, {4, 33}, {-12, 4}};
const int num_values = sizeof(values) / sizeof(ValueSamples);
Stats::DistData expected_data;
expected_data.type = Stats::Hist;
statistics::DistData expected_data;
expected_data.type = statistics::Hist;
expected_data.bucket_size = 8;
expected_data.min = -16;
expected_data.max_val = 16;
@@ -795,7 +795,7 @@ TEST(StatsHistStorTest, SamplePrepareGrowDownGrowOutOddBuckets)
*/
TEST(StatsHistStorTest, SamplePrepareGrowDownGrowOutEvenBuckets)
{
Stats::HistStor::Params params(4);
statistics::HistStor::Params params(4);
// Setup expected data for the hand-carved values given. Since there
// is a negative value, the min bucket will change, and the bucket size
@@ -804,8 +804,8 @@ TEST(StatsHistStorTest, SamplePrepareGrowDownGrowOutEvenBuckets)
ValueSamples values[] =
{{0, 5}, {1, 2}, {2, 99}, {3, 12}, {-12, 4}};
const int num_values = sizeof(values) / sizeof(ValueSamples);
Stats::DistData expected_data;
expected_data.type = Stats::Hist;
statistics::DistData expected_data;
expected_data.type = statistics::Hist;
expected_data.bucket_size = 8;
expected_data.min = -16;
expected_data.max_val = 8;
@@ -826,7 +826,7 @@ TEST(StatsHistStorTest, SamplePrepareGrowDownGrowOutEvenBuckets)
*/
TEST(StatsHistStorTest, SamplePrepareMultipleGrowOddBuckets)
{
Stats::HistStor::Params params(5);
statistics::HistStor::Params params(5);
// Setup expected data for the hand-carved values given. This adds quite
// a few positive and negative samples, and the bucket size will grow to
@@ -836,8 +836,8 @@ TEST(StatsHistStorTest, SamplePrepareMultipleGrowOddBuckets)
ValueSamples values[] =
{{0, 5}, {7, 2}, {31, 99}, {-8, 12}, {127, 4}, {-120, 53}, {-50, 1}};
const int num_values = sizeof(values) / sizeof(ValueSamples);
Stats::DistData expected_data;
expected_data.type = Stats::Hist;
statistics::DistData expected_data;
expected_data.type = statistics::Hist;
expected_data.bucket_size = 64;
expected_data.min = -128;
expected_data.max_val = 128;
@@ -859,7 +859,7 @@ TEST(StatsHistStorTest, SamplePrepareMultipleGrowOddBuckets)
*/
TEST(StatsHistStorTest, SamplePrepareMultipleGrowEvenBuckets)
{
Stats::HistStor::Params params(4);
statistics::HistStor::Params params(4);
// Setup expected data for the hand-carved values given. This adds quite
// a few positive and negative samples, and the bucket size will grow to
@@ -868,8 +868,8 @@ TEST(StatsHistStorTest, SamplePrepareMultipleGrowEvenBuckets)
ValueSamples values[] =
{{0, 5}, {7, 2}, {31, 99}, {-8, 12}, {127, 4}, {-120, 53}, {-50, 1}};
const int num_values = sizeof(values) / sizeof(ValueSamples);
Stats::DistData expected_data;
expected_data.type = Stats::Hist;
statistics::DistData expected_data;
expected_data.type = statistics::Hist;
expected_data.bucket_size = 64;
expected_data.min = -128;
expected_data.max_val = 64;
@@ -886,9 +886,9 @@ TEST(StatsHistStorTest, SamplePrepareMultipleGrowEvenBuckets)
/** Test resetting storage. */
TEST(StatsHistStorTest, Reset)
{
Stats::HistStor::Params params(4);
statistics::HistStor::Params params(4);
MockInfo info(&params);
Stats::HistStor stor(&info);
statistics::HistStor stor(&info);
// Setup expected data for the hand-carved values given. This adds quite
// a few positive and negative samples, and the bucket size will grow to
@@ -904,8 +904,8 @@ TEST(StatsHistStorTest, Reset)
// Reset storage, and make sure all data has been cleared:
// Bkt0=[0,1[ , Bkt1=[1,2[, Bkt2=[2,3[, Bkt3=[3,4[
stor.reset(&info);
Stats::DistData expected_data;
expected_data.type = Stats::Hist;
statistics::DistData expected_data;
expected_data.type = statistics::Hist;
expected_data.bucket_size = 1;
expected_data.min = 0;
expected_data.max_val = 3;
@@ -918,13 +918,13 @@ TEST(StatsHistStorTest, Reset)
/** Test whether adding storages with different sizes triggers an assertion. */
TEST(StatsHistStorDeathTest, AddDifferentSize)
{
Stats::HistStor::Params params(4);
statistics::HistStor::Params params(4);
MockInfo info(&params);
Stats::HistStor stor(&info);
statistics::HistStor stor(&info);
Stats::HistStor::Params params2(5);
statistics::HistStor::Params params2(5);
MockInfo info2(&params2);
Stats::HistStor stor2(&info2);
statistics::HistStor stor2(&info2);
ASSERT_DEATH(stor.add(&stor2), ".+");
}
@@ -932,15 +932,15 @@ TEST(StatsHistStorDeathTest, AddDifferentSize)
/** Test whether adding storages with different min triggers an assertion. */
TEST(StatsHistStorDeathTest, AddDifferentMin)
{
Stats::HistStor::Params params(4);
statistics::HistStor::Params params(4);
MockInfo info(&params);
Stats::HistStor stor(&info);
statistics::HistStor stor(&info);
stor.sample(-1, 3);
// On creation, the storage's min is zero
Stats::HistStor::Params params2(4);
statistics::HistStor::Params params2(4);
MockInfo info2(&params2);
Stats::HistStor stor2(&info2);
statistics::HistStor stor2(&info2);
ASSERT_DEATH(stor.add(&stor2), ".+");
}
@@ -949,40 +949,40 @@ TEST(StatsHistStorDeathTest, AddDifferentMin)
/** Test merging two histograms. */
TEST(StatsHistStorTest, Add)
{
Stats::HistStor::Params params(4);
statistics::HistStor::Params params(4);
MockInfo info(&params);
// Setup first storage. Buckets are:
// Bkt0=[0,16[, Bkt1=[16,32[, Bkt2=[32,48[, Bkt3=[58,64[
Stats::HistStor stor(&info);
statistics::HistStor stor(&info);
ValueSamples values[] = {{0, 5}, {3, 2}, {20, 37}, {32, 18}};
int num_values = sizeof(values) / sizeof(ValueSamples);
for (int i = 0; i < num_values; i++) {
stor.sample(values[i].value, values[i].numSamples);
}
Stats::DistData data;
statistics::DistData data;
stor.prepare(&info, data);
// Setup second storage. Buckets are:
// Bkt0=[0,32[, Bkt1=[32,64[, Bkt2=[64,96[, Bkt3=[96,128[
Stats::HistStor stor2(&info);
statistics::HistStor stor2(&info);
ValueSamples values2[] = {{10, 10}, {0, 1}, {80, 4}, {17, 100}, {95, 79}};
int num_values2 = sizeof(values2) / sizeof(ValueSamples);
for (int i = 0; i < num_values2; i++) {
stor2.sample(values2[i].value, values2[i].numSamples);
}
Stats::DistData data2;
statistics::DistData data2;
stor2.prepare(&info, data2);
// Perform the merge
stor.add(&stor2);
Stats::DistData merge_data;
statistics::DistData merge_data;
stor.prepare(&info, merge_data);
// Setup expected data. Buckets are:
// Bkt0=[0,32[, Bkt1=[32,64[, Bkt2=[64,96[, Bkt3=[96,128[
Stats::DistData expected_data;
expected_data.type = Stats::Hist;
statistics::DistData expected_data;
expected_data.type = statistics::Hist;
expected_data.bucket_size = 32;
expected_data.min = 0;
expected_data.max = 127;
@@ -1010,9 +1010,9 @@ TEST(StatsHistStorTest, Add)
*/
TEST(StatsSampleStorTest, ZeroReset)
{
Stats::SampleStor stor(nullptr);
Stats::Counter val = 10;
Stats::Counter num_samples = 5;
statistics::SampleStor stor(nullptr);
statistics::Counter val = 10;
statistics::Counter num_samples = 5;
ASSERT_TRUE(stor.zero());
@@ -1027,20 +1027,20 @@ TEST(StatsSampleStorTest, ZeroReset)
/** Test setting and getting value from storage. */
TEST(StatsSampleStorTest, SamplePrepare)
{
Stats::SampleStor stor(nullptr);
statistics::SampleStor stor(nullptr);
ValueSamples values[] = {{10, 5}, {1234, 2}, {0xFFFFFFFF, 18}};
int num_values = sizeof(values) / sizeof(ValueSamples);
Stats::Counter val;
Stats::DistData data;
Stats::DistData expected_data;
Stats::SampleStor::Params params;
statistics::Counter val;
statistics::DistData data;
statistics::DistData expected_data;
statistics::SampleStor::Params params;
MockInfo info(&params);
// Simple test with one value being sampled
stor.sample(values[0].value, values[0].numSamples);
stor.prepare(&info, data);
val = values[0].value * values[0].numSamples;
expected_data.type = Stats::Deviation;
expected_data.type = statistics::Deviation;
expected_data.sum = val;
expected_data.squares = values[0].value * val;
expected_data.samples = values[0].numSamples;
@@ -1079,11 +1079,11 @@ TEST(StatsSampleStorTest, SamplePrepare)
/** The size is always 1, no matter which functions have been called. */
TEST(StatsSampleStorTest, Size)
{
Stats::SampleStor stor(nullptr);
Stats::Counter val = 10;
Stats::Counter num_samples = 5;
Stats::DistData data;
Stats::SampleStor::Params params;
statistics::SampleStor stor(nullptr);
statistics::Counter val = 10;
statistics::Counter num_samples = 5;
statistics::DistData data;
statistics::SampleStor::Params params;
MockInfo info(&params);
ASSERT_EQ(stor.size(), 1);
@@ -1104,9 +1104,9 @@ TEST(StatsSampleStorTest, Size)
*/
TEST(StatsAvgSampleStorTest, ZeroReset)
{
Stats::AvgSampleStor stor(nullptr);
Stats::Counter val = 10;
Stats::Counter num_samples = 5;
statistics::AvgSampleStor stor(nullptr);
statistics::Counter val = 10;
statistics::Counter num_samples = 5;
ASSERT_TRUE(stor.zero());
@@ -1121,20 +1121,20 @@ TEST(StatsAvgSampleStorTest, ZeroReset)
/** Test setting and getting value from storage. */
TEST(StatsAvgSampleStorTest, SamplePrepare)
{
Stats::AvgSampleStor stor(nullptr);
statistics::AvgSampleStor stor(nullptr);
ValueSamples values[] = {{10, 5}, {1234, 2}, {0xFFFFFFFF, 18}};
int num_values = sizeof(values) / sizeof(ValueSamples);
Stats::Counter val;
Stats::DistData data;
Stats::DistData expected_data;
Stats::AvgSampleStor::Params params;
statistics::Counter val;
statistics::DistData data;
statistics::DistData expected_data;
statistics::AvgSampleStor::Params params;
MockInfo info(&params);
// Simple test with one value being sampled
stor.sample(values[0].value, values[0].numSamples);
stor.prepare(&info, data);
val = values[0].value * values[0].numSamples;
expected_data.type = Stats::Deviation;
expected_data.type = statistics::Deviation;
expected_data.sum = val;
expected_data.squares = values[0].value * val;
ASSERT_EQ(data.type, expected_data.type);
@@ -1174,11 +1174,11 @@ TEST(StatsAvgSampleStorTest, SamplePrepare)
/** The size is always 1, no matter which functions have been called. */
TEST(StatsAvgSampleStorTest, Size)
{
Stats::AvgSampleStor stor(nullptr);
Stats::Counter val = 10;
Stats::Counter num_samples = 5;
Stats::DistData data;
Stats::AvgSampleStor::Params params;
statistics::AvgSampleStor stor(nullptr);
statistics::Counter val = 10;
statistics::Counter num_samples = 5;
statistics::DistData data;
statistics::AvgSampleStor::Params params;
MockInfo info(&params);
ASSERT_EQ(stor.size(), 1);
@@ -1199,9 +1199,9 @@ TEST(StatsAvgSampleStorTest, Size)
*/
TEST(StatsSparseHistStorTest, ZeroReset)
{
Stats::SparseHistStor stor(nullptr);
Stats::Counter val = 10;
Stats::Counter num_samples = 5;
statistics::SparseHistStor stor(nullptr);
statistics::Counter val = 10;
statistics::Counter num_samples = 5;
ASSERT_TRUE(stor.zero());
@@ -1216,11 +1216,11 @@ TEST(StatsSparseHistStorTest, ZeroReset)
/** Test setting and getting value from storage. */
TEST(StatsSparseHistStorTest, SamplePrepare)
{
Stats::SparseHistStor stor(nullptr);
statistics::SparseHistStor stor(nullptr);
ValueSamples values[] = {{10, 5}, {1234, 2}, {0xFFFFFFFF, 18}};
int num_values = sizeof(values) / sizeof(ValueSamples);
Stats::Counter total_samples;
Stats::SparseHistData data;
statistics::Counter total_samples;
statistics::SparseHistData data;
// Simple test with one value being sampled
stor.sample(values[0].value, values[0].numSamples);

View File

@@ -64,7 +64,9 @@ constexpr auto Nan = std::numeric_limits<float>::quiet_NaN();
} // anonymous namespace
namespace Stats {
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
std::list<Info *> &statsList();
@@ -390,7 +392,7 @@ VectorPrint::operator()(std::ostream &stream) const
}
}
if (flags.isSet(::Stats::total)) {
if (flags.isSet(::statistics::total)) {
print.pdf = Nan;
print.cdf = Nan;
print.name = base + "total";
@@ -688,7 +690,7 @@ Text::visit(const Vector2dInfo &info)
std::vector<std::string> total_subname;
total_subname.push_back("total");
if (info.flags.isSet(::Stats::total) && (info.x > 1)) {
if (info.flags.isSet(::statistics::total) && (info.x > 1)) {
print.name = statName(info.name);
print.subnames = total_subname;
print.desc = info.desc;
@@ -812,4 +814,4 @@ initText(const std::string &filename, bool desc, bool spaces)
return &text;
}
} // namespace Stats
} // namespace statistics

View File

@@ -45,11 +45,14 @@
#include <stack>
#include <string>
#include "base/compiler.hh"
#include "base/output.hh"
#include "base/stats/output.hh"
#include "base/stats/types.hh"
#include "base/output.hh"
namespace Stats {
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
class Text : public Output
{
@@ -101,6 +104,6 @@ std::string ValueToString(Result value, int precision);
Output *initText(const std::string &filename, bool desc, bool spaces);
} // namespace Stats
} // namespace statistics
#endif // __BASE_STATS_TEXT_HH__

View File

@@ -33,9 +33,12 @@
#include <map>
#include <vector>
#include "base/compiler.hh"
#include "base/types.hh"
namespace Stats {
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
/** All counters are of 64-bit values. */
typedef double Counter;
@@ -54,6 +57,6 @@ typedef std::vector<Result> VResult;
typedef unsigned int size_type;
typedef unsigned int off_type;
} // namespace Stats
} // namespace statistics
#endif // __BASE_STATS_TYPES_HH__

View File

@@ -38,41 +38,43 @@
* Convenience macros to declare the unit of a stat.
*/
#define UNIT_CYCLE GEM5_DEPRECATED_MACRO( \
UNIT_CYCLE, Stats::units::Cycle::get(), \
"Use Stats::units::Cycle::get()")
UNIT_CYCLE, statistics::units::Cycle::get(), \
"Use statistics::units::Cycle::get()")
#define UNIT_TICK GEM5_DEPRECATED_MACRO( \
UNIT_TICK, Stats::units::Tick::get(), "Use Stats::units::Tick::get()")
UNIT_TICK, statistics::units::Tick::get(), "Use statistics::units::Tick::get()")
#define UNIT_SECOND GEM5_DEPRECATED_MACRO( \
UNIT_SECOND, Stats::units::Second::get(), \
"Use Stats::units::Second::get()")
UNIT_SECOND, statistics::units::Second::get(), \
"Use statistics::units::Second::get()")
#define UNIT_BIT GEM5_DEPRECATED_MACRO( \
UNIT_BIT, Stats::units::Bit::get(), "Use Stats::units::Bit::get()")
UNIT_BIT, statistics::units::Bit::get(), "Use statistics::units::Bit::get()")
#define UNIT_BYTE GEM5_DEPRECATED_MACRO( \
UNIT_BYTE, Stats::units::Byte::get(), "Use Stats::units::Byte::get()")
UNIT_BYTE, statistics::units::Byte::get(), "Use statistics::units::Byte::get()")
#define UNIT_JOULE GEM5_DEPRECATED_MACRO( \
UNIT_JOULE, Stats::units::Joule::get(), \
"Use Stats::units::Joule::get()")
UNIT_JOULE, statistics::units::Joule::get(), \
"Use statistics::units::Joule::get()")
#define UNIT_VOLT GEM5_DEPRECATED_MACRO( \
UNIT_VOLD, Stats::units::Volt::get(), "Use Stats::units::Volt::get()")
UNIT_VOLD, statistics::units::Volt::get(), "Use statistics::units::Volt::get()")
#define UNIT_CELSIUS GEM5_DEPRECATED_MACRO( \
UNIT_CELSIUS, Stats::units::DegreeCelsius::get(), \
"Use Stats::units::DegreeCelsius::get()")
UNIT_CELSIUS, statistics::units::DegreeCelsius::get(), \
"Use statistics::units::DegreeCelsius::get()")
#define UNIT_RATE(T1, T2) GEM5_DEPRECATED_MACRO( \
UNIT_RATE, (Stats::units::Rate<T1, T2>::get()), \
"Use Stats::units::Rate<T1, T2>::get()")
UNIT_RATE, (statistics::units::Rate<T1, T2>::get()), \
"Use statistics::units::Rate<T1, T2>::get()")
#define UNIT_RATIO GEM5_DEPRECATED_MACRO( \
UNIT_RATIO, Stats::units::Ratio::get(), \
"Use Stats::units::Ratio::get()")
UNIT_RATIO, statistics::units::Ratio::get(), \
"Use statistics::units::Ratio::get()")
#define UNIT_COUNT GEM5_DEPRECATED_MACRO( \
UNIT_COUNT, Stats::units::Count::get(), \
"Use Stats::units::Count::get()")
UNIT_COUNT, statistics::units::Count::get(), \
"Use statistics::units::Count::get()")
#define UNIT_WATT GEM5_DEPRECATED_MACRO( \
UNIT_WATT, Stats::units::Watt::get(), "Use Stats::units::Watt::get()")
UNIT_WATT, statistics::units::Watt::get(), "Use statistics::units::Watt::get()")
#define UNIT_UNSPECIFIED GEM5_DEPRECATED_MACRO( \
UNIT_UNSPECIFIED, Stats::units::Unspecified::get(), \
"Use Stats::units::Unspecified::get()")
UNIT_UNSPECIFIED, statistics::units::Unspecified::get(), \
"Use statistics::units::Unspecified::get()")
namespace Stats {
GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
namespace statistics
{
/**
* Units for Stats.
@@ -337,10 +339,10 @@ class Unspecified : public Base
template <typename T1, typename T2>
class Rate : public Base
{
static_assert(std::is_base_of<Base, T1>::value,
"Rate(T1,T2) must have T1 and T2 derived from Stats::units::Base");
static_assert(std::is_base_of<Base, T2>::value,
"Rate(T1,T2) must have T1 and T2 derived from Stats::units::Base");
static_assert(std::is_base_of<Base, T1>::value, "Rate(T1,T2) must have "
"T1 and T2 derived from statistics::units::Base");
static_assert(std::is_base_of<Base, T2>::value, "Rate(T1,T2) must have "
"T1 and T2 derived from statistics::units::Base");
static_assert(!std::is_same<T1, T2>::value ||
std::is_same<T1, Count>::value || std::is_same<T1, Unspecified>::value,
"Rate(T1,T2) must have T1 and T2 of different types; "
@@ -371,6 +373,6 @@ class Rate : public Base
} // namespace units
} // namespace Stats
} // namespace statistics
#endif // __BASE_STATS_UNITS_HH__

View File

@@ -33,103 +33,113 @@
TEST(StatsUnitsTest, Cycle)
{
Stats::units::Cycle *unit = Stats::units::Cycle::get();
ASSERT_EQ(unit->getUnitString(), Stats::units::Cycle::toString());
statistics::units::Cycle *unit = statistics::units::Cycle::get();
ASSERT_EQ(unit->getUnitString(), statistics::units::Cycle::toString());
}
TEST(StatsUnitsTest, Tick)
{
Stats::units::Tick *unit = Stats::units::Tick::get();
ASSERT_EQ(unit->getUnitString(), Stats::units::Tick::toString());
statistics::units::Tick *unit = statistics::units::Tick::get();
ASSERT_EQ(unit->getUnitString(), statistics::units::Tick::toString());
}
TEST(StatsUnitsTest, Second)
{
Stats::units::Second *unit = Stats::units::Second::get();
ASSERT_EQ(unit->getUnitString(), Stats::units::Second::toString());
statistics::units::Second *unit = statistics::units::Second::get();
ASSERT_EQ(unit->getUnitString(), statistics::units::Second::toString());
}
TEST(StatsUnitsTest, Bit)
{
Stats::units::Bit *unit = Stats::units::Bit::get();
ASSERT_EQ(unit->getUnitString(), Stats::units::Bit::toString());
statistics::units::Bit *unit = statistics::units::Bit::get();
ASSERT_EQ(unit->getUnitString(), statistics::units::Bit::toString());
}
TEST(StatsUnitsTest, Byte)
{
Stats::units::Byte *unit = Stats::units::Byte::get();
ASSERT_EQ(unit->getUnitString(), Stats::units::Byte::toString());
statistics::units::Byte *unit = statistics::units::Byte::get();
ASSERT_EQ(unit->getUnitString(), statistics::units::Byte::toString());
}
TEST(StatsUnitsTest, Watt)
{
Stats::units::Watt *unit = Stats::units::Watt::get();
ASSERT_EQ(unit->getUnitString(), Stats::units::Watt::toString());
statistics::units::Watt *unit = statistics::units::Watt::get();
ASSERT_EQ(unit->getUnitString(), statistics::units::Watt::toString());
}
TEST(StatsUnitsTest, Joule)
{
Stats::units::Joule *unit = Stats::units::Joule::get();
ASSERT_EQ(unit->getUnitString(), Stats::units::Joule::toString());
statistics::units::Joule *unit = statistics::units::Joule::get();
ASSERT_EQ(unit->getUnitString(), statistics::units::Joule::toString());
}
TEST(StatsUnitsTest, Volt)
{
Stats::units::Volt *unit = Stats::units::Volt::get();
ASSERT_EQ(unit->getUnitString(), Stats::units::Volt::toString());
statistics::units::Volt *unit = statistics::units::Volt::get();
ASSERT_EQ(unit->getUnitString(), statistics::units::Volt::toString());
}
TEST(StatsUnitsTest, DegreeCelsius)
{
Stats::units::DegreeCelsius *unit = Stats::units::DegreeCelsius::get();
ASSERT_EQ(unit->getUnitString(), Stats::units::DegreeCelsius::toString());
statistics::units::DegreeCelsius *unit =
statistics::units::DegreeCelsius::get();
ASSERT_EQ(unit->getUnitString(),
statistics::units::DegreeCelsius::toString());
}
TEST(StatsUnitsTest, Count)
{
Stats::units::Count *unit = Stats::units::Count::get();
ASSERT_EQ(unit->getUnitString(), Stats::units::Count::toString());
statistics::units::Count *unit = statistics::units::Count::get();
ASSERT_EQ(unit->getUnitString(), statistics::units::Count::toString());
}
TEST(StatsUnitsTest, Rate1)
{
Stats::units::Rate<Stats::units::Count, Stats::units::Count> *unit =
Stats::units::Rate<Stats::units::Count, Stats::units::Count>::get();
statistics::units::Rate<statistics::units::Count,
statistics::units::Count> *unit =
statistics::units::Rate<statistics::units::Count,
statistics::units::Count>::get();
ASSERT_EQ(unit->getUnitString(), "(Count/Count)");
ASSERT_EQ(unit->getUnitString(), (Stats::units::Rate<Stats::units::Count,
Stats::units::Count>::toString()));
ASSERT_EQ(unit->getUnitString(),
(statistics::units::Rate<statistics::units::Count,
statistics::units::Count>::toString()));
}
TEST(StatsUnitsTest, Rate2)
{
Stats::units::Rate<Stats::units::Tick, Stats::units::Second> *unit =
Stats::units::Rate<Stats::units::Tick, Stats::units::Second>::get();
statistics::units::Rate<statistics::units::Tick,
statistics::units::Second> *unit =
statistics::units::Rate<statistics::units::Tick,
statistics::units::Second>::get();
ASSERT_EQ(unit->getUnitString(), "(Tick/Second)");
ASSERT_EQ(unit->getUnitString(), (Stats::units::Rate<Stats::units::Tick,
Stats::units::Second>::toString()));
ASSERT_EQ(unit->getUnitString(),
(statistics::units::Rate<statistics::units::Tick,
statistics::units::Second>::toString()));
}
TEST(StatsUnitsTest, RateOfRates)
{
typedef Stats::units::Rate<Stats::units::Bit, Stats::units::Second>
BitPerSecond;
typedef Stats::units::Rate<Stats::units::Count, Stats::units::Cycle>
CountPerCycle;
Stats::units::Rate<BitPerSecond, CountPerCycle> *unit =
Stats::units::Rate<BitPerSecond, CountPerCycle>::get();
typedef statistics::units::Rate<statistics::units::Bit,
statistics::units::Second> BitPerSecond;
typedef statistics::units::Rate<statistics::units::Count,
statistics::units::Cycle> CountPerCycle;
statistics::units::Rate<BitPerSecond, CountPerCycle> *unit =
statistics::units::Rate<BitPerSecond, CountPerCycle>::get();
ASSERT_EQ(unit->getUnitString(), "((Bit/Second)/(Count/Cycle))");
ASSERT_EQ(unit->getUnitString(),
(Stats::units::Rate<BitPerSecond, CountPerCycle>::toString()));
(statistics::units::Rate<BitPerSecond, CountPerCycle>::toString()));
}
TEST(StatsUnitsTest, Ratio)
{
Stats::units::Ratio *unit = Stats::units::Ratio::get();
ASSERT_EQ(unit->getUnitString(), Stats::units::Ratio::toString());
statistics::units::Ratio *unit = statistics::units::Ratio::get();
ASSERT_EQ(unit->getUnitString(), statistics::units::Ratio::toString());
}
TEST(StatsUnitsTest, Unspecified)
{
Stats::units::Unspecified *unit = Stats::units::Unspecified::get();
ASSERT_EQ(unit->getUnitString(), Stats::units::Unspecified::toString());
statistics::units::Unspecified *unit =
statistics::units::Unspecified::get();
ASSERT_EQ(unit->getUnitString(),
statistics::units::Unspecified::toString());
}