From 42d5d8950d849aa4b855aa62834cd5fdee1a91a8 Mon Sep 17 00:00:00 2001 From: Gereon Kremer Date: Thu, 11 Mar 2021 21:20:19 +0100 Subject: 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. --- test/unit/util/stats_black.cpp | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'test/unit/util/stats_black.cpp') 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; -- cgit v1.2.3