diff options
author | Gereon Kremer <gkremer@stanford.edu> | 2021-03-11 21:20:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-11 20:20:19 +0000 |
commit | 42d5d8950d849aa4b855aa62834cd5fdee1a91a8 (patch) | |
tree | 2cbb6d9b283c05fc12ba9ad8495fa84a57375af6 /test/unit/util/stats_black.cpp | |
parent | dc679ed380aabc62aadfbb4033c02c5a27ae903c (diff) |
First refactoring of statistics classes (#6105)
This PR does a first round of refactoring on the statistics, in particular the Stat class and derived classes.
It significantly shrinks the class hierarchy, modernizes some code (e.g. use std::chrono instead of clock_gettime), removes unused features (e.g. nesting of statistics) and does some general cleanup and consolidation.
Subsequent PRs are planned to change the ownership model (right now every module owns the Stat object) which makes the whole register / unregister mechanism obsolete.
Diffstat (limited to 'test/unit/util/stats_black.cpp')
-rw-r--r-- | test/unit/util/stats_black.cpp | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/test/unit/util/stats_black.cpp b/test/unit/util/stats_black.cpp index 336bb33fc..3363ba132 100644 --- a/test/unit/util/stats_black.cpp +++ b/test/unit/util/stats_black.cpp @@ -24,23 +24,12 @@ #include "lib/clock_gettime.h" #include "test.h" #include "util/statistics_registry.h" +#include "util/stats_histogram.h" +#include "util/stats_timer.h" namespace CVC4 { namespace test { -/** - * This is a duplicate of operator== in statistics_registry.h. - * This is duplicated here to try to avoid polluting top namepsace. - * - * If operator== is in the CVC4 namespace, there are some circumstances - * where clang does not find this operator. - */ -bool operator==(const timespec& a, const timespec& b) -{ - // assumes a.tv_nsec and b.tv_nsec are in range - return a.tv_sec == b.tv_sec && a.tv_nsec == b.tv_nsec; -} - class TestUtilBlackStats : public TestInternal { }; @@ -84,22 +73,22 @@ TEST_F(TestUtilBlackStats, stats) ASSERT_EQ(histIntStat.getName(), "hist-int"); ASSERT_EQ(histPfRuleStat.getName(), "hist-pfrule"); - ASSERT_EQ(refStr.getData(), empty); - ASSERT_EQ(refStr2.getData(), bar); + ASSERT_EQ(refStr.get(), empty); + ASSERT_EQ(refStr2.get(), bar); empty = "a different string"; bar += " and with an addition"; - ASSERT_EQ(refStr.getData(), empty); - ASSERT_EQ(refStr2.getData(), bar); + ASSERT_EQ(refStr.get(), empty); + ASSERT_EQ(refStr2.get(), bar); - ASSERT_EQ(backedStr.getData(), "baz"); + ASSERT_EQ(backedStr.get(), "baz"); baz = "something else"; - ASSERT_EQ(backedStr.getData(), "baz"); + ASSERT_EQ(backedStr.get(), "baz"); - ASSERT_EQ(sInt.getData(), 10); - sInt.setData(100); - ASSERT_EQ(sInt.getData(), 100); + ASSERT_EQ(sInt.get(), 10); + sInt.set(100); + ASSERT_EQ(sInt.get(), 100); - ASSERT_TRUE(sTimer.getData() == timespec()); + ASSERT_TRUE(sTimer.get() == std::chrono::nanoseconds()); std::stringstream sstr; |