Print usage count if it's rarely used.

PiperOrigin-RevId: 597083184
pull/15361/head
Protobuf Team Bot 11 months ago committed by Copybara-Service
parent 3b5b6e9f02
commit 7d6198ed42
  1. 3
      src/google/protobuf/compiler/cpp/tools/analyze_profile_proto.cc
  2. 12
      src/google/protobuf/compiler/cpp/tools/analyze_profile_proto_test.cc

@ -440,7 +440,8 @@ static absl::StatusOr<Stats> AnalyzeProfileProto(
stream << " " << analysis.presence << "_PRESENT";
}
if (analysis.usage != PDProtoScale::kDefault) {
stream << " " << analysis.usage << "_USED";
stream << " " << analysis.usage << "_USED("
<< analysis.usage_count << ")";
}
}
if (optimized != PDProtoOptimization::kNone) {

@ -184,12 +184,12 @@ TEST(AnalyzeProfileProtoTest, PrintStatistics) {
options.pool = DescriptorPool::generated_pool();
EXPECT_STREQ(AnalyzeToText(info, options).c_str(),
R"(Message google::protobuf::compiler::tools::AnalyzeThis
int32 id: RARELY_USED
string optional_string: RARELY_USED
string[] repeated_string: LIKELY_PRESENT RARELY_USED
AnalyzeChild optional_child: LIKELY_PRESENT RARELY_USED LAZY
AnalyzeChild[] repeated_child: LIKELY_PRESENT RARELY_USED
Nested nested: RARELY_USED
int32 id: RARELY_USED(100)
string optional_string: RARELY_USED(100)
string[] repeated_string: LIKELY_PRESENT RARELY_USED(100)
AnalyzeChild optional_child: LIKELY_PRESENT RARELY_USED(1) LAZY
AnalyzeChild[] repeated_child: LIKELY_PRESENT RARELY_USED(100)
Nested nested: RARELY_USED(100)
========
singular_lazy_num=1
singular_lazy_0usage_num=0

Loading…
Cancel
Save