Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
benchmark.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 
16 #ifndef IMPALA_UTIL_BENCHMARK_H
17 #define IMPALA_UTIL_BENCHMARK_H
18 
19 #include <string>
20 #include <vector>
21 
22 namespace impala {
23 
31 class Benchmark {
32  public:
34  Benchmark(const std::string& name);
35 
39  typedef void (*BenchmarkFunction)(int iters, void*);
40 
46  int AddBenchmark(const std::string& name, BenchmarkFunction fn, void* args,
47  int baseline_idx = 0);
48 
50  std::string Measure();
51 
53  static std::string GetMachineInfo();
54 
55  private:
56  friend class BenchmarkTest;
57 
64  static double Measure(BenchmarkFunction function, void* args,
65  int max_time = 1000, int initial_batch_size = 1000);
66 
67  struct BenchmarkResult {
68  std::string name;
70  void* args;
71  double rate;
73  };
74 
75  std::string name_;
76  std::vector<BenchmarkResult> benchmarks_;
77 };
78 
79 }
80 
81 #endif
int AddBenchmark(const std::string &name, BenchmarkFunction fn, void *args, int baseline_idx=0)
Definition: benchmark.cc:70
static std::string GetMachineInfo()
Output machine/build configuration as a string.
Definition: benchmark.cc:124
std::string Measure()
Runs all the benchmarks and returns the result in a formatted string.
Definition: benchmark.cc:83
std::string name_
Definition: benchmark.h:75
void(* BenchmarkFunction)(int iters, void *)
Definition: benchmark.h:39
std::vector< BenchmarkResult > benchmarks_
Definition: benchmark.h:76
Benchmark(const std::string &name)
Name of the microbenchmark. This is outputted in the result.
Definition: benchmark.cc:64
string name
Definition: cpu-info.cc:50