summaryrefslogtreecommitdiffstats
path: root/libcxx/utils/google-benchmark/src/reporter.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/utils/google-benchmark/src/reporter.cc')
-rw-r--r--libcxx/utils/google-benchmark/src/reporter.cc31
1 files changed, 22 insertions, 9 deletions
diff --git a/libcxx/utils/google-benchmark/src/reporter.cc b/libcxx/utils/google-benchmark/src/reporter.cc
index 64742426cd3..5d2fa05a2b2 100644
--- a/libcxx/utils/google-benchmark/src/reporter.cc
+++ b/libcxx/utils/google-benchmark/src/reporter.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "benchmark/reporter.h"
+#include "benchmark/benchmark.h"
#include "timers.h"
#include <cstdlib>
@@ -22,7 +22,6 @@
#include <vector>
#include "check.h"
-#include "stat.h"
namespace benchmark {
@@ -31,17 +30,29 @@ BenchmarkReporter::BenchmarkReporter()
BenchmarkReporter::~BenchmarkReporter() {}
-void BenchmarkReporter::PrintBasicContext(std::ostream *out_ptr,
+void BenchmarkReporter::PrintBasicContext(std::ostream *out,
Context const &context) {
- CHECK(out_ptr) << "cannot be null";
- auto &Out = *out_ptr;
-
- Out << "Run on (" << context.num_cpus << " X " << context.mhz_per_cpu
- << " MHz CPU " << ((context.num_cpus > 1) ? "s" : "") << ")\n";
+ CHECK(out) << "cannot be null";
+ auto &Out = *out;
Out << LocalDateTimeString() << "\n";
- if (context.cpu_scaling_enabled) {
+ const CPUInfo &info = context.cpu_info;
+ Out << "Run on (" << info.num_cpus << " X "
+ << (info.cycles_per_second / 1000000.0) << " MHz CPU "
+ << ((info.num_cpus > 1) ? "s" : "") << ")\n";
+ if (info.caches.size() != 0) {
+ Out << "CPU Caches:\n";
+ for (auto &CInfo : info.caches) {
+ Out << " L" << CInfo.level << " " << CInfo.type << " "
+ << (CInfo.size / 1000) << "K";
+ if (CInfo.num_sharing != 0)
+ Out << " (x" << (info.num_cpus / CInfo.num_sharing) << ")";
+ Out << "\n";
+ }
+ }
+
+ if (info.scaling_enabled) {
Out << "***WARNING*** CPU scaling is enabled, the benchmark "
"real time measurements may be noisy and will incur extra "
"overhead.\n";
@@ -53,6 +64,8 @@ void BenchmarkReporter::PrintBasicContext(std::ostream *out_ptr,
#endif
}
+BenchmarkReporter::Context::Context() : cpu_info(CPUInfo::Get()) {}
+
double BenchmarkReporter::Run::GetAdjustedRealTime() const {
double new_time = real_accumulated_time * GetTimeUnitMultiplier(time_unit);
if (iterations != 0) new_time /= static_cast<double>(iterations);
OpenPOWER on IntegriCloud