blob: 3a7d241dbd08b7037fd346d78b940c696988aafc [file] [log] [blame]
Clement Courbetac74acd2018-04-04 11:37:06 +00001//===-- BenchmarkResult.h ---------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9///
10/// \file
11/// Defines classes to represent measurements and serialize/deserialize them to
12// Yaml.
13///
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_TOOLS_LLVM_EXEGESIS_BENCHMARKRESULT_H
17#define LLVM_TOOLS_LLVM_EXEGESIS_BENCHMARKRESULT_H
18
19#include "llvm/ADT/StringRef.h"
20#include "llvm/Support/YAMLTraits.h"
21#include <string>
22#include <vector>
23
24namespace exegesis {
25
Clement Courbeta66bfaa42018-05-15 13:07:05 +000026struct InstructionBenchmarkKey {
27 // The LLVM opcode name.
28 std::string OpcodeName;
29 // The benchmark mode.
30 std::string Mode;
31 // An opaque configuration, that can be used to separate several benchmarks of
32 // the same instruction under different configurations.
33 std::string Config;
Clement Courbetac74acd2018-04-04 11:37:06 +000034};
35
36struct BenchmarkMeasure {
37 std::string Key;
38 double Value;
39 std::string DebugString;
40};
41
42// The result of an instruction benchmark.
43struct InstructionBenchmark {
Clement Courbeta66bfaa42018-05-15 13:07:05 +000044 InstructionBenchmarkKey Key;
Clement Courbetac74acd2018-04-04 11:37:06 +000045 std::string CpuName;
46 std::string LLVMTriple;
Clement Courbet8fb6e402018-04-04 12:01:46 +000047 int NumRepetitions = 0;
Clement Courbetac74acd2018-04-04 11:37:06 +000048 std::vector<BenchmarkMeasure> Measurements;
49 std::string Error;
Clement Courbeta66bfaa42018-05-15 13:07:05 +000050 std::string Info;
Clement Courbetac74acd2018-04-04 11:37:06 +000051
52 static InstructionBenchmark readYamlOrDie(llvm::StringRef Filename);
Clement Courbet0e69e2d2018-05-17 10:52:18 +000053 static std::vector<InstructionBenchmark>
Clement Courbetac74acd2018-04-04 11:37:06 +000054
Clement Courbet0e69e2d2018-05-17 10:52:18 +000055 // Read functions.
56 readYamlsOrDie(llvm::StringRef Filename);
57 void readYamlFrom(llvm::StringRef InputContent);
58
59 // Write functions, non-const because of YAML traits.
60 void writeYamlTo(llvm::raw_ostream &S);
Clement Courbetac74acd2018-04-04 11:37:06 +000061 void writeYamlOrDie(const llvm::StringRef Filename);
62};
63
64} // namespace exegesis
65
66#endif // LLVM_TOOLS_LLVM_EXEGESIS_BENCHMARKRESULT_H