All About Timing - Manak-org/Manak GitHub Wiki

Let us start by timing the simplest function.

MANAK_AUTO_BENCHMARK_CASE(B1)
{
  SetUp;
  
  MEASURE
  (
    Code;
  )
  
  TearDown;
}

Here the code inside the 'MEASURE' block will be timed. Important thing to remember is that 'MEASURE' block does not change the scope.

There can be any number of 'MEASURE' blocks inside a benchmark case. The time of all the 'Measure' blocks will be sumed.

MANAK_AUTO_BENCHMARK_CASE(B1)
{
  SetUp Code;
  
  MEASURE
  (
    Code
  )
  
  TearDown Code;
  
  MEASURE
  (
    Code;
  )
  
  TearDown Code;
}

'MEASURE' blocks can also appear user created function.

void fun(size_t a)
{
  SetUp;
  
  MEASURE
  (
    Code;
  )
  
  TearDown;
}

MANAK_ADD_CASE(MANAK_CREATE_BENCHMARK_WITH_TEMPLATE(Test, fun)->AddArgs(0));

'MANAK_ADD_BENCHMARK_WITH_TEMPLATE' creates a parametrized benchmark case. For more information on parametrized benchmarks check [Parametrized Benchmarks](Parametrized Benchmarks).