1 //===-- BenchmarkRunner interface -------------------------------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIBC_UTILS_BENCHMARK_MEMORY_BENCHMARK_MAIN_H
10 #define LLVM_LIBC_UTILS_BENCHMARK_MEMORY_BENCHMARK_MAIN_H
11 
12 #include "LibcBenchmark.h"
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/StringRef.h"
15 
16 namespace llvm {
17 namespace libc_benchmarks {
18 
19 // Each memory function benchmark implements this interface.
20 // It is used by the main function to run all benchmarks in a uniform manner.
21 class BenchmarkRunner {
22 public:
~BenchmarkRunner()23   virtual ~BenchmarkRunner() {}
24 
25   // Returns a list of all available functions to test.
26   virtual ArrayRef<StringRef> getFunctionNames() const = 0;
27 
28   // Performs the benchmarking for a particular FunctionName and Size.
29   virtual BenchmarkResult benchmark(const BenchmarkOptions &Options,
30                                     StringRef FunctionName, size_t Size) = 0;
31 };
32 
33 } // namespace libc_benchmarks
34 } // namespace llvm
35 
36 #endif // LLVM_LIBC_UTILS_BENCHMARK_MEMORY_BENCHMARK_MAIN_H
37