Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::Benchmark Class Reference

#include <benchmark.h>

Collaboration diagram for impala::Benchmark:

Classes

struct  BenchmarkResult
 

Public Types

typedef void(* BenchmarkFunction )(int iters, void *)
 

Public Member Functions

 Benchmark (const std::string &name)
 Name of the microbenchmark. This is outputted in the result. More...
 
int AddBenchmark (const std::string &name, BenchmarkFunction fn, void *args, int baseline_idx=0)
 
std::string Measure ()
 Runs all the benchmarks and returns the result in a formatted string. More...
 

Static Public Member Functions

static std::string GetMachineInfo ()
 Output machine/build configuration as a string. More...
 

Static Private Member Functions

static double Measure (BenchmarkFunction function, void *args, int max_time=1000, int initial_batch_size=1000)
 

Private Attributes

std::string name_
 
std::vector< BenchmarkResultbenchmarks_
 

Friends

class BenchmarkTest
 

Detailed Description

Utility class for microbenchmarks. This can be utilized to create a benchmark suite. For example: Benchmark suite("benchmark"); suite.AddBenchmark("Implementation #1", Implementation1Fn, data); suite.AddBenchmark("Implementation #2", Implementation2Fn, data); ... string result = suite.Measure();

Definition at line 31 of file benchmark.h.

Member Typedef Documentation

typedef void(* impala::Benchmark::BenchmarkFunction)(int iters, void *)

Function to benchmark. The function should run iters time (to minimize function call overhead). The second argument is opaque and is whatever data the test function needs to execute.

Definition at line 39 of file benchmark.h.

Constructor & Destructor Documentation

impala::Benchmark::Benchmark ( const std::string &  name)

Name of the microbenchmark. This is outputted in the result.

Definition at line 64 of file benchmark.cc.

Member Function Documentation

int impala::Benchmark::AddBenchmark ( const std::string &  name,
BenchmarkFunction  fn,
void *  args,
int  baseline_idx = 0 
)

Add a benchmark with 'name' to the suite. The first benchmark is assumed to be the baseline. Reporting will be done relative to that. Returns a unique index for this benchmark. baseline_idx is the base function to compare this one against. Specify -1 to not have a baseline.

Definition at line 70 of file benchmark.cc.

References benchmarks_, impala::name, and impala::Benchmark::BenchmarkResult::name.

Referenced by main(), impala::InPredicateBenchmark::RunDecimalBenchmark(), impala::InPredicateBenchmark::RunIntBenchmark(), and impala::InPredicateBenchmark::RunStringBenchmark().

string impala::Benchmark::GetMachineInfo ( )
static

Output machine/build configuration as a string.

Definition at line 124 of file benchmark.cc.

References impala::CpuInfo::model_name().

Referenced by main().

string impala::Benchmark::Measure ( )

Runs all the benchmarks and returns the result in a formatted string.

Definition at line 83 of file benchmark.cc.

References benchmarks_, name_, and padding.

Referenced by main(), impala::BenchmarkTest::Measure(), impala::InPredicateBenchmark::RunDecimalBenchmark(), impala::InPredicateBenchmark::RunIntBenchmark(), and impala::InPredicateBenchmark::RunStringBenchmark().

double impala::Benchmark::Measure ( BenchmarkFunction  function,
void *  args,
int  max_time = 1000,
int  initial_batch_size = 1000 
)
staticprivate

Benchmarks the 'function' returning the result as invocations per ms. args is an opaque argument passed as the second argument to the function. max_time is the total time to benchmark the function, in ms. initial_batch_size is the initial batch size to the run the function. The harness function will automatically ramp up the batch_size. The benchmark will take at least initial_batch_size * function invocation time.

Definition at line 28 of file benchmark.cc.

References impala::CpuInfo::cycles_per_ms(), impala::StopWatch::ElapsedTime(), impala::StopWatch::Start(), and impala::StopWatch::Stop().

Friends And Related Function Documentation

friend class BenchmarkTest
friend

Definition at line 56 of file benchmark.h.

Member Data Documentation

std::vector<BenchmarkResult> impala::Benchmark::benchmarks_
private

Definition at line 76 of file benchmark.h.

Referenced by AddBenchmark(), and Measure().

std::string impala::Benchmark::name_
private

Definition at line 75 of file benchmark.h.

Referenced by Measure().


The documentation for this class was generated from the following files: