summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
blob: cf9bcece99afd5bf85806a57bfe5f83998d4db68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//===-- BenchmarkResult.h ---------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// Defines classes to represent measurements and serialize/deserialize them to
//  Yaml.
///
//===----------------------------------------------------------------------===//

#ifndef LLVM_TOOLS_LLVM_EXEGESIS_BENCHMARKRESULT_H
#define LLVM_TOOLS_LLVM_EXEGESIS_BENCHMARKRESULT_H

#include "llvm/ADT/StringRef.h"
#include "llvm/Support/YAMLTraits.h"
#include <string>
#include <vector>

namespace exegesis {

struct InstructionBenchmarkKey {
  // The LLVM opcode name.
  std::string OpcodeName;
  // The benchmark mode.
  std::string Mode;
  // An opaque configuration, that can be used to separate several benchmarks of
  // the same instruction under different configurations.
  std::string Config;
};

struct BenchmarkMeasure {
  std::string Key;
  double Value;
  std::string DebugString;
};

// The result of an instruction benchmark.
struct InstructionBenchmark {
  InstructionBenchmarkKey Key;
  std::string CpuName;
  std::string LLVMTriple;
  int NumRepetitions = 0;
  std::vector<BenchmarkMeasure> Measurements;
  std::string Error;
  std::string Info;

  static InstructionBenchmark readYamlOrDie(llvm::StringRef Filename);
  static std::vector<InstructionBenchmark> readYamlsOrDie(llvm::StringRef Filename);

  // Unfortunately this function is non const because of YAML traits.
  void writeYamlOrDie(const llvm::StringRef Filename);
};

} // namespace exegesis

#endif // LLVM_TOOLS_LLVM_EXEGESIS_BENCHMARKRESULT_H
OpenPOWER on IntegriCloud