1a8c51b3fSopenharmony_ci#ifndef BENCHMARK_API_INTERNAL_H
2a8c51b3fSopenharmony_ci#define BENCHMARK_API_INTERNAL_H
3a8c51b3fSopenharmony_ci
4a8c51b3fSopenharmony_ci#include <cmath>
5a8c51b3fSopenharmony_ci#include <iosfwd>
6a8c51b3fSopenharmony_ci#include <limits>
7a8c51b3fSopenharmony_ci#include <memory>
8a8c51b3fSopenharmony_ci#include <string>
9a8c51b3fSopenharmony_ci#include <vector>
10a8c51b3fSopenharmony_ci
11a8c51b3fSopenharmony_ci#include "benchmark/benchmark.h"
12a8c51b3fSopenharmony_ci#include "commandlineflags.h"
13a8c51b3fSopenharmony_ci
14a8c51b3fSopenharmony_cinamespace benchmark {
15a8c51b3fSopenharmony_cinamespace internal {
16a8c51b3fSopenharmony_ci
17a8c51b3fSopenharmony_ci// Information kept per benchmark we may want to run
18a8c51b3fSopenharmony_ciclass BenchmarkInstance {
19a8c51b3fSopenharmony_ci public:
20a8c51b3fSopenharmony_ci  BenchmarkInstance(Benchmark* benchmark, int family_index,
21a8c51b3fSopenharmony_ci                    int per_family_instance_index,
22a8c51b3fSopenharmony_ci                    const std::vector<int64_t>& args, int threads);
23a8c51b3fSopenharmony_ci
24a8c51b3fSopenharmony_ci  const BenchmarkName& name() const { return name_; }
25a8c51b3fSopenharmony_ci  int family_index() const { return family_index_; }
26a8c51b3fSopenharmony_ci  int per_family_instance_index() const { return per_family_instance_index_; }
27a8c51b3fSopenharmony_ci  AggregationReportMode aggregation_report_mode() const {
28a8c51b3fSopenharmony_ci    return aggregation_report_mode_;
29a8c51b3fSopenharmony_ci  }
30a8c51b3fSopenharmony_ci  TimeUnit time_unit() const { return time_unit_; }
31a8c51b3fSopenharmony_ci  bool measure_process_cpu_time() const { return measure_process_cpu_time_; }
32a8c51b3fSopenharmony_ci  bool use_real_time() const { return use_real_time_; }
33a8c51b3fSopenharmony_ci  bool use_manual_time() const { return use_manual_time_; }
34a8c51b3fSopenharmony_ci  BigO complexity() const { return complexity_; }
35a8c51b3fSopenharmony_ci  BigOFunc* complexity_lambda() const { return complexity_lambda_; }
36a8c51b3fSopenharmony_ci  const std::vector<Statistics>& statistics() const { return statistics_; }
37a8c51b3fSopenharmony_ci  int repetitions() const { return repetitions_; }
38a8c51b3fSopenharmony_ci  double min_time() const { return min_time_; }
39a8c51b3fSopenharmony_ci  double min_warmup_time() const { return min_warmup_time_; }
40a8c51b3fSopenharmony_ci  IterationCount iterations() const { return iterations_; }
41a8c51b3fSopenharmony_ci  int threads() const { return threads_; }
42a8c51b3fSopenharmony_ci  void Setup() const;
43a8c51b3fSopenharmony_ci  void Teardown() const;
44a8c51b3fSopenharmony_ci
45a8c51b3fSopenharmony_ci  State Run(IterationCount iters, int thread_id, internal::ThreadTimer* timer,
46a8c51b3fSopenharmony_ci            internal::ThreadManager* manager,
47a8c51b3fSopenharmony_ci            internal::PerfCountersMeasurement* perf_counters_measurement) const;
48a8c51b3fSopenharmony_ci
49a8c51b3fSopenharmony_ci private:
50a8c51b3fSopenharmony_ci  BenchmarkName name_;
51a8c51b3fSopenharmony_ci  Benchmark& benchmark_;
52a8c51b3fSopenharmony_ci  const int family_index_;
53a8c51b3fSopenharmony_ci  const int per_family_instance_index_;
54a8c51b3fSopenharmony_ci  AggregationReportMode aggregation_report_mode_;
55a8c51b3fSopenharmony_ci  const std::vector<int64_t>& args_;
56a8c51b3fSopenharmony_ci  TimeUnit time_unit_;
57a8c51b3fSopenharmony_ci  bool measure_process_cpu_time_;
58a8c51b3fSopenharmony_ci  bool use_real_time_;
59a8c51b3fSopenharmony_ci  bool use_manual_time_;
60a8c51b3fSopenharmony_ci  BigO complexity_;
61a8c51b3fSopenharmony_ci  BigOFunc* complexity_lambda_;
62a8c51b3fSopenharmony_ci  UserCounters counters_;
63a8c51b3fSopenharmony_ci  const std::vector<Statistics>& statistics_;
64a8c51b3fSopenharmony_ci  int repetitions_;
65a8c51b3fSopenharmony_ci  double min_time_;
66a8c51b3fSopenharmony_ci  double min_warmup_time_;
67a8c51b3fSopenharmony_ci  IterationCount iterations_;
68a8c51b3fSopenharmony_ci  int threads_;  // Number of concurrent threads to us
69a8c51b3fSopenharmony_ci
70a8c51b3fSopenharmony_ci  typedef void (*callback_function)(const benchmark::State&);
71a8c51b3fSopenharmony_ci  callback_function setup_ = nullptr;
72a8c51b3fSopenharmony_ci  callback_function teardown_ = nullptr;
73a8c51b3fSopenharmony_ci};
74a8c51b3fSopenharmony_ci
75a8c51b3fSopenharmony_cibool FindBenchmarksInternal(const std::string& re,
76a8c51b3fSopenharmony_ci                            std::vector<BenchmarkInstance>* benchmarks,
77a8c51b3fSopenharmony_ci                            std::ostream* Err);
78a8c51b3fSopenharmony_ci
79a8c51b3fSopenharmony_cibool IsZero(double n);
80a8c51b3fSopenharmony_ci
81a8c51b3fSopenharmony_ciBENCHMARK_EXPORT
82a8c51b3fSopenharmony_ciConsoleReporter::OutputOptions GetOutputOptions(bool force_no_color = false);
83a8c51b3fSopenharmony_ci
84a8c51b3fSopenharmony_ci}  // end namespace internal
85a8c51b3fSopenharmony_ci}  // end namespace benchmark
86a8c51b3fSopenharmony_ci
87a8c51b3fSopenharmony_ci#endif  // BENCHMARK_API_INTERNAL_H
88