From: Joel Rosdahl Date: Sun, 15 Aug 2021 19:41:03 +0000 (+0200) Subject: feat: Print statistics IDs instead of descriptions to debug log X-Git-Tag: v4.4~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=190d2f2ec75321726813e73e8d8b9548520631fe;p=thirdparty%2Fccache.git feat: Print statistics IDs instead of descriptions to debug log This is in preparation for future statistics counters that won’t have human-readable descriptions. (The statistics IDs are human-readable enough.) --- diff --git a/src/ccache.cpp b/src/ccache.cpp index 309a7f91c..8eec88487 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -1856,7 +1856,7 @@ log_result_to_debug_log(Context& ctx) } core::Statistics statistics(ctx.storage.primary.get_statistics_updates()); - for (const auto& message : statistics.get_statistics_messages()) { + for (const auto& message : statistics.get_statistics_ids()) { LOG("Result: {}", message); } } diff --git a/src/core/Statistics.cpp b/src/core/Statistics.cpp index 04f67897d..10ad98d1a 100644 --- a/src/core/Statistics.cpp +++ b/src/core/Statistics.cpp @@ -189,12 +189,6 @@ Statistics::get_statistics_ids() const return get_statistics_fields(m_counters, true); } -std::vector -Statistics::get_statistics_messages() const -{ - return get_statistics_fields(m_counters, false); -} - std::string Statistics::format_config_header(const Config& config) { diff --git a/src/core/Statistics.hpp b/src/core/Statistics.hpp index 39ccbbe28..568023be0 100644 --- a/src/core/Statistics.hpp +++ b/src/core/Statistics.hpp @@ -36,9 +36,6 @@ public: // Return machine-readable strings representing the statistics counters. std::vector get_statistics_ids() const; - // Return human-readable strings representing the statistics counters. - std::vector get_statistics_messages() const; - // Format config header in human-readable format. static std::string format_config_header(const Config& config); diff --git a/test/suites/base.bash b/test/suites/base.bash index 61a854b58..a9839009d 100644 --- a/test/suites/base.bash +++ b/test/suites/base.bash @@ -374,7 +374,7 @@ fi TEST "CCACHE_DEBUGDIR" CCACHE_DEBUG=1 CCACHE_DEBUGDIR=debugdir $CCACHE_COMPILE -c test1.c - expect_contains debugdir"$(pwd -P)"/test1.o.ccache-log "Result: cache miss" + expect_contains debugdir"$(pwd -P)"/test1.o.ccache-log "Result: cache_miss" # ------------------------------------------------------------------------- TEST "CCACHE_DISABLE" diff --git a/unittest/test_core_Statistics.cpp b/unittest/test_core_Statistics.cpp index 2a8620e98..39262596b 100644 --- a/unittest/test_core_Statistics.cpp +++ b/unittest/test_core_Statistics.cpp @@ -47,19 +47,4 @@ TEST_CASE("get_statistics_ids") CHECK(Statistics(counters).get_statistics_ids() == expected); } -TEST_CASE("get_statistics_messages") -{ - TestContext test_context; - - StatisticsCounters counters; - counters.increment(Statistic::cache_size_kibibyte); - counters.increment(Statistic::cache_miss); - counters.increment(Statistic::direct_cache_hit); - counters.increment(Statistic::autoconf_test); - - std::vector expected = { - "autoconf compile/link", "cache hit (direct)", "cache miss"}; - CHECK(Statistics(counters).get_statistics_messages() == expected); -} - TEST_SUITE_END();