]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Correctly represent statistics counters > 1 in log and stats log
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 9 May 2022 16:43:03 +0000 (18:43 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 11 May 2022 18:49:14 +0000 (20:49 +0200)
src/core/Statistics.cpp
test/suites/stats_log.bash

index 7786b261499f21be7614f814ba7120bce3cd59c8..c1f0a52c79a9da23a8f362d7c479f635e615783a 100644 (file)
@@ -162,8 +162,10 @@ Statistics::get_statistics_ids() const
 {
   std::vector<std::string> result;
   for (const auto& field : k_statistics_fields) {
-    if (m_counters.get(field.statistic) != 0 && !(field.flags & FLAG_NOZERO)) {
-      result.emplace_back(field.id);
+    if (!(field.flags & FLAG_NOZERO)) {
+      for (size_t i = 0; i < m_counters.get(field.statistic); ++i) {
+        result.emplace_back(field.id);
+      }
     }
   }
   std::sort(result.begin(), result.end());
index e90efaf5479fdc90f9bbce5849c90f69df712645..1ad3b930df292fbd358ceedf743192cbd85f9019 100644 (file)
@@ -10,18 +10,26 @@ SUITE_stats_log() {
 
     $CCACHE_COMPILE -c test.c
     expect_stat direct_cache_hit 0
+    expect_stat preprocessed_cache_miss 1
     expect_stat cache_miss 1
+    expect_stat primary_storage_hit 0
+    expect_stat primary_storage_miss 2
 
     $CCACHE_COMPILE -c test.c
     expect_stat direct_cache_hit 1
+    expect_stat preprocessed_cache_miss 1
     expect_stat cache_miss 1
+    expect_stat primary_storage_hit 2
+    expect_stat primary_storage_miss 2
 
     expect_content stats.log "# test.c
 cache_miss
 direct_cache_miss
 preprocessed_cache_miss
 primary_storage_miss
+primary_storage_miss
 # test.c
 direct_cache_hit
+primary_storage_hit
 primary_storage_hit"
 }