1 //===-- UopsBenchmarkRunner.cpp ---------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "UopsBenchmarkRunner.h"
16 UopsBenchmarkRunner::~UopsBenchmarkRunner() = default;
18 Expected
<std::vector
<BenchmarkMeasure
>>
19 UopsBenchmarkRunner::runMeasurements(const FunctionExecutor
&Executor
) const {
20 std::vector
<BenchmarkMeasure
> Result
;
21 const PfmCountersInfo
&PCI
= State
.getPfmCounters();
23 for (const auto *IssueCounter
= PCI
.IssueCounters
,
24 *IssueCounterEnd
= PCI
.IssueCounters
+ PCI
.NumIssueCounters
;
25 IssueCounter
!= IssueCounterEnd
; ++IssueCounter
) {
26 if (!IssueCounter
->Counter
)
28 auto ExpectedCounterValue
= Executor
.runAndSample(IssueCounter
->Counter
);
29 if (!ExpectedCounterValue
)
30 return ExpectedCounterValue
.takeError();
31 Result
.push_back(BenchmarkMeasure::Create(IssueCounter
->ProcResName
,
32 (*ExpectedCounterValue
)[0]));
35 if (const char *const UopsCounter
= PCI
.UopsCounter
) {
36 auto ExpectedCounterValue
= Executor
.runAndSample(UopsCounter
);
37 if (!ExpectedCounterValue
)
38 return ExpectedCounterValue
.takeError();
40 BenchmarkMeasure::Create("NumMicroOps", (*ExpectedCounterValue
)[0]));
42 return std::move(Result
);
45 } // namespace exegesis