[Workflow] Roll back some settings since they caused more issues
[llvm-project.git] / libc / benchmarks / LibcBenchmark.cpp
blob014b855fe987fd5487462948c52f241e3f1cbdd4
1 //===-- Benchmark function -----------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "LibcBenchmark.h"
10 #include "llvm/ADT/StringRef.h"
11 #include "llvm/TargetParser/Host.h"
13 namespace llvm {
14 namespace libc_benchmarks {
16 void checkRequirements() {
17 const auto &CpuInfo = benchmark::CPUInfo::Get();
18 if (CpuInfo.scaling == benchmark::CPUInfo::ENABLED)
19 report_fatal_error(
20 "CPU scaling is enabled, the benchmark real time measurements may be "
21 "noisy and will incur extra overhead.");
24 HostState HostState::get() {
25 const auto &CpuInfo = benchmark::CPUInfo::Get();
26 HostState H;
27 H.CpuFrequency = CpuInfo.cycles_per_second;
28 H.CpuName = llvm::sys::getHostCPUName().str();
29 for (const auto &BenchmarkCacheInfo : CpuInfo.caches) {
30 CacheInfo CI;
31 CI.Type = BenchmarkCacheInfo.type;
32 CI.Level = BenchmarkCacheInfo.level;
33 CI.Size = BenchmarkCacheInfo.size;
34 CI.NumSharing = BenchmarkCacheInfo.num_sharing;
35 H.Caches.push_back(std::move(CI));
37 return H;
40 } // namespace libc_benchmarks
41 } // namespace llvm