blob: cf9bcece99afd5bf85806a57bfe5f83998d4db68 [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 Courbet7b7c27a2018-05-14 09:01:22 +000053 static std::vector<InstructionBenchmark> readYamlsOrDie(llvm::StringRef Filename);
Clement Courbetac74acd2018-04-04 11:37:06 +000054
55 // Unfortunately this function is non const because of YAML traits.
56 void writeYamlOrDie(const llvm::StringRef Filename);
57};
58
59} // namespace exegesis
60
61#endif // LLVM_TOOLS_LLVM_EXEGESIS_BENCHMARKRESULT_H