Skip to content

Commit 8cd2a72

Browse files
andreas-abelcopybara-github
authored andcommitted
Output overridden cache sizes.
PiperOrigin-RevId: 741560798 Change-Id: I296b97987b04038777fde39131a0d939bff6217d
1 parent 5d55d8d commit 8cd2a72

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

fleetbench/common/common.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,4 +268,21 @@ bool UseExplicitIterationCounts() {
268268
!FindInCommandLine("--benchmark_list_tests");
269269
}
270270

271+
bool FleetbenchReporter::ReportContext(
272+
const benchmark::BenchmarkReporter::Context& context) {
273+
reporter_->SetOutputStream(&this->GetOutputStream());
274+
reporter_->SetErrorStream(&this->GetErrorStream());
275+
bool result = reporter_->ReportContext(context);
276+
if (absl::GetFlag(FLAGS_L1_data_size).has_value() ||
277+
absl::GetFlag(FLAGS_L2_size).has_value() ||
278+
absl::GetFlag(FLAGS_L3_size).has_value()) {
279+
auto& err = this->GetErrorStream();
280+
err << "Effective CPU Cache Sizes:\n";
281+
err << " L1 Data " << GetCacheSize(1, "Data") / 1024 << " KiB\n";
282+
err << " L2 " << GetCacheSize(2) / 1024 << " KiB\n";
283+
err << " L3 " << GetCacheSize(3) / 1024 << " KiB\n";
284+
}
285+
return result;
286+
}
287+
271288
} // namespace fleetbench

fleetbench/common/common.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,7 @@ class FleetbenchReporter : public benchmark::BenchmarkReporter {
117117
reporter_->ReportRunsConfig(min_time, has_explicit_iters, iters);
118118
}
119119

120-
bool ReportContext(
121-
const benchmark::BenchmarkReporter::Context& context) override {
122-
reporter_->SetOutputStream(&this->GetOutputStream());
123-
reporter_->SetErrorStream(&this->GetErrorStream());
124-
return reporter_->ReportContext(context);
125-
}
120+
bool ReportContext(const benchmark::BenchmarkReporter::Context&) override;
126121

127122
void Finalize() override { reporter_->Finalize(); }
128123

0 commit comments

Comments
 (0)