summaryrefslogtreecommitdiffstats
path: root/metrics
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-03-04 00:19:23 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2017-03-08 21:38:39 +0000
commitdc28bbbd37e04b254b9a3f5a3f47709fbf22371e (patch)
treece15bb4025cb99cfa4e4ce0e6831859036305b4a /metrics
parent032de590a77215ac3625e380dd94fbe5fd8aa19f (diff)
Deinline destructors/constructors
Diffstat (limited to 'metrics')
-rw-r--r--metrics/src/tests/metricmanagertest.cpp132
-rw-r--r--metrics/src/tests/snapshottest.cpp226
-rw-r--r--metrics/src/tests/stresstest.cpp116
3 files changed, 264 insertions, 210 deletions
diff --git a/metrics/src/tests/metricmanagertest.cpp b/metrics/src/tests/metricmanagertest.cpp
index 72a4a287f2c..7159207e0ff 100644
--- a/metrics/src/tests/metricmanagertest.cpp
+++ b/metrics/src/tests/metricmanagertest.cpp
@@ -63,17 +63,22 @@ struct SubMetricSet : public MetricSet
DoubleValueMetric val2;
SumMetric<DoubleValueMetric> valsum;
- SubMetricSet(const Metric::String & name, MetricSet* owner)
- : MetricSet(name, "sub", "sub desc", owner, "sub"),
- val1("val1", "tag4 snaptest", "val1 desc", this),
- val2("val2", "tag5", "val2 desc", this),
- valsum("valsum", "tag4 snaptest", "valsum desc", this)
- {
- valsum.addMetricToSum(val1);
- valsum.addMetricToSum(val2);
- }
+ SubMetricSet(const Metric::String & name, MetricSet* owner);
+ ~SubMetricSet();
};
+
+SubMetricSet::SubMetricSet(const Metric::String & name, MetricSet* owner)
+ : MetricSet(name, "sub", "sub desc", owner, "sub"),
+ val1("val1", "tag4 snaptest", "val1 desc", this),
+ val2("val2", "tag5", "val2 desc", this),
+ valsum("valsum", "tag4 snaptest", "valsum desc", this)
+{
+ valsum.addMetricToSum(val1);
+ valsum.addMetricToSum(val2);
+}
+SubMetricSet::~SubMetricSet() { }
+
struct MultiSubMetricSet
{
MetricSet set;
@@ -82,21 +87,23 @@ struct MultiSubMetricSet
SubMetricSet b;
SumMetric<MetricSet> sum;
- MultiSubMetricSet(MetricSet* owner)
- : set("multisub", "multisub", "", owner),
- count("count", "snaptest", "counter", &set),
- a("a", &set),
- b("b", &set),
- sum("sum", "snaptest", "", &set)
- {
- sum.addMetricToSum(a);
- sum.addMetricToSum(b);
- }
-
+ MultiSubMetricSet(MetricSet* owner);
+ ~MultiSubMetricSet();
};
-struct TestMetricSet
+MultiSubMetricSet::MultiSubMetricSet(MetricSet* owner)
+ : set("multisub", "multisub", "", owner),
+ count("count", "snaptest", "counter", &set),
+ a("a", &set),
+ b("b", &set),
+ sum("sum", "snaptest", "", &set)
{
+ sum.addMetricToSum(a);
+ sum.addMetricToSum(b);
+}
+ MultiSubMetricSet::~MultiSubMetricSet() { }
+
+struct TestMetricSet {
MetricSet set;
DoubleValueMetric val1;
DoubleValueMetric val2;
@@ -109,23 +116,27 @@ struct TestMetricSet
SubMetricSet val9;
MultiSubMetricSet val10;
- TestMetricSet()
- : set("temp", "test", "desc of test set"),
- val1("val1", "tag1", "val1 desc", &set),
- val2("val2", "tag1 tag2", "val2 desc", &set),
- val3("val3", "tag2 tag3", "val3 desc", &set),
- val4("val4", "tag3", "val4 desc", &set),
- val5("val5", "tag2", "val5 desc", &set),
- val6("val6", "tag4 snaptest", "val6 desc", &set),
- val7("val7", "", "val7 desc", &set),
- val8("val8", "tag6", "val8 desc", &set),
- val9("sub", &set),
- val10(&set)
- {
- }
-
+ TestMetricSet();
+ ~TestMetricSet();
};
+TestMetricSet::TestMetricSet()
+ : set("temp", "test", "desc of test set"),
+ val1("val1", "tag1", "val1 desc", &set),
+ val2("val2", "tag1 tag2", "val2 desc", &set),
+ val3("val3", "tag2 tag3", "val3 desc", &set),
+ val4("val4", "tag3", "val4 desc", &set),
+ val5("val5", "tag2", "val5 desc", &set),
+ val6("val6", "tag4 snaptest", "val6 desc", &set),
+ val7("val7", "", "val7 desc", &set),
+ val8("val8", "tag6", "val8 desc", &set),
+ val9("sub", &set),
+ val10(&set)
+{ }
+
+TestMetricSet::~TestMetricSet() { }
+
+
struct MetricNameVisitor : public MetricVisitor {
std::ostringstream ost;
bool debug;
@@ -898,12 +909,8 @@ class JsonMetricWrapper
std::string _jsonText;
vespalib::Slime _tree;
public:
- JsonMetricWrapper(const std::string& jsonText)
- : _jsonText(jsonText)
- {
- vespalib::slime::JsonFormat::decode(
- vespalib::Memory(jsonText), _tree);
- }
+ JsonMetricWrapper(const std::string& jsonText);
+ ~JsonMetricWrapper();
// XXX ideally all these should be const, but is not clear how/if it's
// possible to get a const cursor into the underlying tree.
@@ -945,20 +952,29 @@ public:
}
};
+JsonMetricWrapper::JsonMetricWrapper(const std::string& jsonText)
+ : _jsonText(jsonText)
+{
+ vespalib::slime::JsonFormat::decode(vespalib::Memory(jsonText), _tree);
+}
+JsonMetricWrapper::~JsonMetricWrapper() { }
+
struct DimensionTestMetricSet : MetricSet
{
DoubleValueMetric val1;
LongCountMetric val2;
- DimensionTestMetricSet(MetricSet* owner = nullptr)
- : MetricSet("temp", {{"foo", "megafoo"}, {"bar", "hyperbar"}},
- "", owner),
- val1("val1", "tag1", "val1 desc", this), // Legacy tag; not dimension
- val2("val2", {{"baz", "superbaz"}}, "val2 desc", this)
- {
- }
+ DimensionTestMetricSet(MetricSet* owner = nullptr);
+ ~DimensionTestMetricSet();
};
+DimensionTestMetricSet::DimensionTestMetricSet(MetricSet* owner)
+ : MetricSet("temp", {{"foo", "megafoo"}, {"bar", "hyperbar"}}, "", owner),
+ val1("val1", "tag1", "val1 desc", this),
+ val2("val2", {{"baz", "superbaz"}}, "val2 desc", this)
+{ }
+DimensionTestMetricSet::~DimensionTestMetricSet() { }
+
} // anon ns
void
@@ -1027,8 +1043,7 @@ struct DimensionOverridableTestMetricSet : MetricSet
MetricSet* owner = nullptr)
: MetricSet("temp", {{"foo", dimValue}}, "", owner),
val("val", "", "val desc", this)
- {
- }
+ { }
};
struct SameNamesTestMetricSet : MetricSet
@@ -1036,14 +1051,17 @@ struct SameNamesTestMetricSet : MetricSet
DimensionOverridableTestMetricSet set1;
DimensionOverridableTestMetricSet set2;
- SameNamesTestMetricSet()
- : MetricSet("outer", {{"fancy", "stuff"}}, ""),
- set1("bar", this),
- set2("baz", this)
- {
- }
+ SameNamesTestMetricSet();
+ ~SameNamesTestMetricSet();
};
+SameNamesTestMetricSet::SameNamesTestMetricSet()
+ : MetricSet("outer", {{"fancy", "stuff"}}, ""),
+ set1("bar", this),
+ set2("baz", this)
+{ }
+SameNamesTestMetricSet::~SameNamesTestMetricSet() { }
+
} // anon ns
void
diff --git a/metrics/src/tests/snapshottest.cpp b/metrics/src/tests/snapshottest.cpp
index 253b7b4f2de..2527a048df6 100644
--- a/metrics/src/tests/snapshottest.cpp
+++ b/metrics/src/tests/snapshottest.cpp
@@ -38,63 +38,71 @@ struct SubSubMetricSet : public MetricSet {
LoadMetric<DoubleAverageMetric> loadAverage;
SumMetric<DoubleAverageMetric> averageSum;
- SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_,
- MetricSet* owner = 0)
- : MetricSet(name, "", "", owner),
- loadTypes(loadTypes_),
- incVal(1),
- count1("count1", "", "", this),
- count2("count2", "", "", this),
- loadCount(loadTypes, LongCountMetric("loadCount", "", ""), this),
- countSum("countSum", "", "", this),
- value1("value1", "", "", this),
- value2("value2", "", "", this),
- loadValue(loadTypes, DoubleValueMetric("loadValue", "", ""), this),
- valueSum("valueSum", "", "", this),
- average1("average1", "", "", this),
- average2("average2", "", "", this),
- loadAverage(loadTypes, DoubleAverageMetric("loadAverage", "", ""),
- this),
- averageSum("averageSum", "", "", this)
- {
- countSum.addMetricToSum(count1);
- countSum.addMetricToSum(count2);
- valueSum.addMetricToSum(value1);
- valueSum.addMetricToSum(value2);
- averageSum.addMetricToSum(average1);
- averageSum.addMetricToSum(average2);
- }
+ SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0);
+ ~SubSubMetricSet();
+ virtual MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+ metrics::MetricSet* owner, bool includeUnused) const;
+ void incValues();
+};
- virtual MetricSet* clone(std::vector<Metric::LP>& ownerList,
- CopyType copyType, metrics::MetricSet* owner,
- bool includeUnused) const
- {
- if (copyType == INACTIVE) {
- return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused);
- }
- return (SubSubMetricSet*) (new SubSubMetricSet(
- getName(), loadTypes, owner))
- ->assignValues(*this);
+SubSubMetricSet::SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner)
+ : MetricSet(name, "", "", owner),
+ loadTypes(loadTypes_),
+ incVal(1),
+ count1("count1", "", "", this),
+ count2("count2", "", "", this),
+ loadCount(loadTypes, LongCountMetric("loadCount", "", ""), this),
+ countSum("countSum", "", "", this),
+ value1("value1", "", "", this),
+ value2("value2", "", "", this),
+ loadValue(loadTypes, DoubleValueMetric("loadValue", "", ""), this),
+ valueSum("valueSum", "", "", this),
+ average1("average1", "", "", this),
+ average2("average2", "", "", this),
+ loadAverage(loadTypes, DoubleAverageMetric("loadAverage", "", ""), this),
+ averageSum("averageSum", "", "", this)
+{
+ countSum.addMetricToSum(count1);
+ countSum.addMetricToSum(count2);
+ valueSum.addMetricToSum(value1);
+ valueSum.addMetricToSum(value2);
+ averageSum.addMetricToSum(average1);
+ averageSum.addMetricToSum(average2);
+}
+SubSubMetricSet::~SubSubMetricSet() { }
+
+MetricSet*
+SubSubMetricSet::clone(std::vector<Metric::LP>& ownerList,
+ CopyType copyType, metrics::MetricSet* owner,
+ bool includeUnused) const
+{
+ if (copyType == INACTIVE) {
+ return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused);
}
+ return (SubSubMetricSet*) (new SubSubMetricSet(
+ getName(), loadTypes, owner))
+ ->assignValues(*this);
+}
- void incValues() {
- count1.inc(incVal);
- count2.inc(incVal);
- for (uint32_t i=0; i<loadTypes.size(); ++i) {
- loadCount[loadTypes[i]].inc(incVal);
- }
- value1.set(incVal);
- value2.set(incVal);
- for (uint32_t i=0; i<loadTypes.size(); ++i) {
- loadValue[loadTypes[i]].set(incVal);
- }
- average1.set(incVal);
- average2.set(incVal);
- for (uint32_t i=0; i<loadTypes.size(); ++i) {
- loadAverage[loadTypes[i]].set(incVal);
- }
+void
+SubSubMetricSet::incValues() {
+ count1.inc(incVal);
+ count2.inc(incVal);
+ for (uint32_t i=0; i<loadTypes.size(); ++i) {
+ loadCount[loadTypes[i]].inc(incVal);
}
-};
+ value1.set(incVal);
+ value2.set(incVal);
+ for (uint32_t i=0; i<loadTypes.size(); ++i) {
+ loadValue[loadTypes[i]].set(incVal);
+ }
+ average1.set(incVal);
+ average2.set(incVal);
+ for (uint32_t i=0; i<loadTypes.size(); ++i) {
+ loadAverage[loadTypes[i]].set(incVal);
+ }
+}
+
struct SubMetricSet : public MetricSet {
const LoadTypeSet& loadTypes;
@@ -103,39 +111,47 @@ struct SubMetricSet : public MetricSet {
LoadMetric<SubSubMetricSet> loadSet;
SumMetric<SubSubMetricSet> setSum;
- SubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_,
- MetricSet* owner = 0)
- : MetricSet(name, "", "", owner),
- loadTypes(loadTypes_),
- set1("set1", loadTypes, this),
- set2("set2", loadTypes, this),
- loadSet(loadTypes, *std::unique_ptr<SubSubMetricSet>(
- new SubSubMetricSet("loadSet", loadTypes)), this),
- setSum("setSum", "", "", this)
- {
- setSum.addMetricToSum(set1);
- setSum.addMetricToSum(set2);
- }
+ SubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0);
+ ~SubMetricSet();
- virtual MetricSet* clone(std::vector<Metric::LP>& ownerList,
- CopyType copyType, metrics::MetricSet* owner,
- bool includeUnused) const
- {
- if (copyType == INACTIVE) {
- return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused);
- }
- return (SubMetricSet*) (new SubMetricSet(getName(), loadTypes, owner))
- ->assignValues(*this);
+ MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+ metrics::MetricSet* owner, bool includeUnused) const override;
+
+ void incValues();
+};
+
+SubMetricSet::SubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner)
+ : MetricSet(name, "", "", owner),
+ loadTypes(loadTypes_),
+ set1("set1", loadTypes, this),
+ set2("set2", loadTypes, this),
+ loadSet(loadTypes, *std::unique_ptr<SubSubMetricSet>(new SubSubMetricSet("loadSet", loadTypes)), this),
+ setSum("setSum", "", "", this)
+{
+ setSum.addMetricToSum(set1);
+ setSum.addMetricToSum(set2);
+}
+SubMetricSet::~SubMetricSet() { }
+
+MetricSet*
+SubMetricSet::clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+ metrics::MetricSet* owner, bool includeUnused) const
+{
+ if (copyType == INACTIVE) {
+ return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused);
}
+ return (SubMetricSet*) (new SubMetricSet(getName(), loadTypes, owner))
+ ->assignValues(*this);
+}
- void incValues() {
- set1.incValues();
- set2.incValues();
- for (uint32_t i=0; i<loadTypes.size(); ++i) {
- loadSet[loadTypes[i]].incValues();
- }
+void
+SubMetricSet::incValues() {
+ set1.incValues();
+ set2.incValues();
+ for (uint32_t i=0; i<loadTypes.size(); ++i) {
+ loadSet[loadTypes[i]].incValues();
}
-};
+}
struct TestMetricSet : public MetricSet {
const LoadTypeSet& loadTypes;
@@ -144,29 +160,35 @@ struct TestMetricSet : public MetricSet {
LoadMetric<SubMetricSet> loadSet;
SumMetric<SubMetricSet> setSum;
- TestMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_,
- MetricSet* owner = 0)
- : MetricSet(name, "", "", owner),
- loadTypes(loadTypes_),
- set1("set1", loadTypes, this),
- set2("set2", loadTypes, this),
- loadSet(loadTypes, *std::unique_ptr<SubMetricSet>(
- new SubMetricSet("loadSet", loadTypes)), this),
- setSum("setSum", "", "", this)
- {
- setSum.addMetricToSum(set1);
- setSum.addMetricToSum(set2);
- }
+ TestMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0);
+ ~TestMetricSet();
- void incValues() {
- set1.incValues();
- set2.incValues();
- for (uint32_t i=0; i<loadTypes.size(); ++i) {
- loadSet[loadTypes[i]].incValues();
- }
- }
+ void incValues();
};
+
+TestMetricSet::TestMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner)
+ : MetricSet(name, "", "", owner),
+ loadTypes(loadTypes_),
+ set1("set1", loadTypes, this),
+ set2("set2", loadTypes, this),
+ loadSet(loadTypes, *std::unique_ptr<SubMetricSet>(new SubMetricSet("loadSet", loadTypes)), this),
+ setSum("setSum", "", "", this)
+{
+ setSum.addMetricToSum(set1);
+ setSum.addMetricToSum(set2);
+}
+TestMetricSet::~TestMetricSet() { }
+
+void
+TestMetricSet::incValues() {
+ set1.incValues();
+ set2.incValues();
+ for (uint32_t i=0; i<loadTypes.size(); ++i) {
+ loadSet[loadTypes[i]].incValues();
+ }
+}
+
struct FakeTimer : public MetricManager::Timer {
uint32_t _timeInSecs;
diff --git a/metrics/src/tests/stresstest.cpp b/metrics/src/tests/stresstest.cpp
index a0e56289d4d..9eb13e00a79 100644
--- a/metrics/src/tests/stresstest.cpp
+++ b/metrics/src/tests/stresstest.cpp
@@ -22,58 +22,72 @@ struct StressTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE_REGISTRATION(StressTest);
namespace {
- struct InnerMetricSet : public MetricSet {
- const LoadTypeSet& _loadTypes;
- LongCountMetric _count;
- LongAverageMetric _value1;
- LongAverageMetric _value2;
- SumMetric<LongAverageMetric> _valueSum;
- LoadMetric<LongAverageMetric> _load;
-
- InnerMetricSet(const char* name, const LoadTypeSet& lt,
- MetricSet* owner = 0)
- : MetricSet(name, "", "", owner),
- _loadTypes(lt),
- _count("count", "", "", this),
- _value1("value1", "", "", this),
- _value2("value2", "", "", this),
- _valueSum("valuesum", "", "", this),
- _load(lt, LongAverageMetric("load", "", ""), this)
- {
- _valueSum.addMetricToSum(_value1);
- _valueSum.addMetricToSum(_value2);
- }
+struct InnerMetricSet : public MetricSet {
+ const LoadTypeSet& _loadTypes;
+ LongCountMetric _count;
+ LongAverageMetric _value1;
+ LongAverageMetric _value2;
+ SumMetric<LongAverageMetric> _valueSum;
+ LoadMetric<LongAverageMetric> _load;
+
+ InnerMetricSet(const char* name, const LoadTypeSet& lt, MetricSet* owner = 0);
+ ~InnerMetricSet();
+
+ MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+ MetricSet* owner, bool includeUnused) const override;
+};
+
+InnerMetricSet::InnerMetricSet(const char* name, const LoadTypeSet& lt, MetricSet* owner)
+ : MetricSet(name, "", "", owner),
+ _loadTypes(lt),
+ _count("count", "", "", this),
+ _value1("value1", "", "", this),
+ _value2("value2", "", "", this),
+ _valueSum("valuesum", "", "", this),
+ _load(lt, LongAverageMetric("load", "", ""), this)
+{
+ _valueSum.addMetricToSum(_value1);
+ _valueSum.addMetricToSum(_value2);
+}
+InnerMetricSet::~InnerMetricSet() { }
+
+ MetricSet*
+ InnerMetricSet::clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
+ MetricSet* owner, bool includeUnused) const
+{
+ if (copyType != CLONE) {
+ return MetricSet::clone(ownerList, copyType, owner, includeUnused);
+}
+ InnerMetricSet * myset = new InnerMetricSet(getName().c_str(), _loadTypes, owner);
+ myset->assignValues(*this);
+ return myset;
+}
+
+struct OuterMetricSet : public MetricSet {
+ InnerMetricSet _inner1;
+ InnerMetricSet _inner2;
+ SumMetric<InnerMetricSet> _innerSum;
+ InnerMetricSet _tmp;
+ LoadMetric<InnerMetricSet> _load;
+
+ OuterMetricSet(const LoadTypeSet& lt, MetricSet* owner = 0);
+ ~OuterMetricSet();
+};
+
+OuterMetricSet::OuterMetricSet(const LoadTypeSet& lt, MetricSet* owner)
+ : MetricSet("outer", "", "", owner),
+ _inner1("inner1", lt, this),
+ _inner2("inner2", lt, this),
+ _innerSum("innersum", "", "", this),
+ _tmp("innertmp", lt, 0),
+ _load(lt, _tmp, this)
+{
+ _innerSum.addMetricToSum(_inner1);
+ _innerSum.addMetricToSum(_inner2);
+}
+
+OuterMetricSet::~OuterMetricSet() { }
- MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType,
- MetricSet* owner, bool includeUnused) const override
- {
- if (copyType != CLONE) {
- return MetricSet::clone(ownerList, copyType, owner, includeUnused);
- }
- InnerMetricSet * myset = new InnerMetricSet(getName().c_str(), _loadTypes, owner);
- myset->assignValues(*this);
- return myset;
- }
- };
- struct OuterMetricSet : public MetricSet {
- InnerMetricSet _inner1;
- InnerMetricSet _inner2;
- SumMetric<InnerMetricSet> _innerSum;
- InnerMetricSet _tmp;
- LoadMetric<InnerMetricSet> _load;
-
- OuterMetricSet(const LoadTypeSet& lt, MetricSet* owner = 0)
- : MetricSet("outer", "", "", owner),
- _inner1("inner1", lt, this),
- _inner2("inner2", lt, this),
- _innerSum("innersum", "", "", this),
- _tmp("innertmp", lt, 0),
- _load(lt, _tmp, this)
- {
- _innerSum.addMetricToSum(_inner1);
- _innerSum.addMetricToSum(_inner2);
- }
- };
struct Hammer : public document::Runnable {
typedef vespalib::LinkedPtr<Hammer> LP;