Manak  2.0.0
Automatic Registration

Manak offers auto case and suite registation with a user friendly API. Auto registration can be done anywhere where manak.hpp is included. It cannot be inside any class or a function but it can be inside a namespace.

Auto Registration With Simple Module

Simplest auto benchmark case registration -

#define MANAK_SIMPLE_MODULE bench
#define MANAK_AUTO_MAIN
#define MANAK_INIT
#include <manak/manak.hpp>
{
Code;
}

Any auto registration registers the case or suite to the current suite. When no suite is set the current suite is set to master suite. So in the example above 'MANAK_AUTO_BENCHMARK_CASE' will register 'B1' to master suite.

When iteration, tolerance or success percentage is not specified for any benchmark case the default will be used. See MANAK_DEFAULT_ITERATIONS, MANAK_DEFAULT_TOLERANCE and MANAK_DEFAULT_SP for more details.

The library name is taken as default library name in the simple module. Check out Introduction for how to set default library name of simple module.

Simple Module Auto Case Registration Macros

MANAK_AUTO_BENCHMARK_CASE_TIS

Creates a benchmark case with name, tolerance, iterations and success percentage, and registers it under the current suite.

{
Code;
}

MANAK_AUTO_BENCHMARK_CASE_TI

Creates a benchmark case with name, tolerance and iterations, and registers it under the current suite. The success percentage is taken as the defaut value.

{
Code;
}

MANAK_AUTO_BENCHMARK_CASE_IS

Creates a benchmark case with name, iterations and success percentage, and registers it under the current suite. The tolerance is taken as the default value.

{
Code;
}

MANAK_AUTO_BENCHMARK_CASE_I

Creates benchmark case with name and iterations, and registers it to the current benchmark suite. The tolerance and success percenatge is taken as default.

{
Code;
}

MANAK_AUTO_BENCHMARK_CASE_T

Creates benchmark case with name and tolerance, and registers it to the current benchmark suite. The value of iterations and success percentage is taken to be default.

{
Code;
}

MANAK_AUTO_BENCHMARK_CASE

Creates benchmark case with name, and registers it to the current benchmark suite. Iterations, tolerance and success percentage for the benchmark case are taken to be defaults.

MANAK_ADD_CASE

'MANAK_ADD_CASE' can be used to register manually generated benchmark case. This is especially useful when written function needs to be added as benchmark case.

#define MANAK_SIMPLE_MODULE bench
#define MANAK_AUTO_MAIN
#define MANAK_INIT
#include <manak/manak.hpp>
int fun()
{
Code to benchmark;
}
MANAK_ADD_case(MANAK_BENCHMARK_CASE(B1, fun));

'MANAK_BENCHMARK_CASE' is a directive for manual registration. For more such directives see Manual Registration.

The function to be registered must have no parameters. The function with parameters can used to generate parametrized benchmark cases. See Complete guide on Parametrized Benchmarking for more information. Also see Advance Function Registration for registration of complex functions such as overloaded functions, template functions and class member functions.

Simple Module Auto Suite Registration Macros

MANAK_AUTO_SUITE

Creates a new benchmarking suite with given name and registers it to the current benchmarking suite. It also sets the newly generated benchmarking suite as the current suite.

#define MANAK_SIMPLE_MODULE bench
#define MANAK_AUTO_MAIN
#define MANAK_INIT
#include <manak/manak.hpp>
{
Code;
}

In the above example 'Suite1' will be registered under master suite and 'B1' will be registered under 'Suite1'.

MANAK_AUTO_SUITE_END

Sets the current benchmark suite to the parent of current of benchmark suite.

#define MANAK_SIMPLE_MODULE bench
#define MANAK_AUTO_MAIN
#define MANAK_INIT
#include <manak/manak.hpp>
{
Code;
}
{
Code;
}

In the above example 'B1' will be registered under 'Suite1' but 'B2' will be registered under master suite.

Simple Module Auto Parametrized Benchmark Case Registration Macros

MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_TIS

Creates a parametrized benchmark case with name, function, tolerance, iterations and success percentage. To register use 'MANAK_ADD_CASE'.

int fun(size_t a)
{
(
for(size_t i = 0;i < a;i++);
)
}
MANAK_ADD_CASE(MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_TIS(ForLoops, fun, 10 50, 90)->AddArgs(1000)->AddArgs(2000));

MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_TI

Creates a parametrized benchmark case with name, function, tolerance and iterations. To register use 'MANAK_ADD_CASE'. The value of success percentage is taken as constant.

int fun(size_t a)
{
(
for(size_t i = 0;i < a;i++);
)
}
MANAK_ADD_CASE(MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_TI(ForLoops, fun)->AddArgs(1000)->AddArgs(2000));

MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_IS

Creates a parametrized benchmark case with name, function, iterations and success percentage. To register use 'MANAK_ADD_CASE'. The value of tolerance is taken as constant.

int fun(size_t a)
{
(
for(size_t i = 0;i < a;i++);
)
}
MANAK_ADD_CASE(MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_IS(ForLoops, fun, 10, 90)->AddArgs(1000)->AddArgs(2000));

MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_I

Creates a parametrized benchmark case with name, function and iterations. To register use 'MANAK_ADD_CASE'. The values of tolerance and success percentage are taken as constant.

int fun(size_t a)
{
(
for(size_t i = 0;i < a;i++);
)
}
MANAK_ADD_CASE(MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_I(ForLoops, fun, 10)->AddArgs(1000)->AddArgs(2000));

MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_T

Creates a parametrized benchmark case with name, function and tolerance. To register use 'MANAK_ADD_CASE'. The values of iterations and success percentage are taken as constant.

int fun(size_t a)
{
(
for(size_t i = 0;i < a;i++);
)
}
MANAK_ADD_CASE(MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_I(ForLoops, fun, 10)->AddArgs(1000)->AddArgs(2000));

MANAK_CREATE_BENCHMARK_WITH_TEMPLATE

Creates a parametrized benchmark case with name and function. To register use 'MANAK_ADD_CASE'. The values of tolerance, iterations and success percentage are taken as constant.

int fun(size_t a)
{
(
for(size_t i = 0;i < a;i++);
)
}
MANAK_ADD_CASE(MANAK_CREATE_BENCHMARK_WITH_TEMPLATE(ForLoops, fun)->AddArgs(1000)->AddArgs(2000));

For more advance parametrized benchmark options check Complete guide on Parametrized Benchmarking.

Simple Module Auto Group Registration Macros

MANAK_AUTO_GROUP AND MANAK_AUTO_GROUP_END

'MANAK_AUTO_GROUP' starts a group and registers the cases inside to current suite.

MANAK_ADD_GROUP

Add the manually created group to current suite. Accepts first argument as the group name with complete template specialization. After this any number of argument can be passed which will be directed to initialization of the group.

MANAK_GROUP(TestGroup);
GINIT(size_t a, size_t b)
{
}
MANAK_ADD_GROUP(TestGroup, 10, 10);

Simple Module Auto Group Benchmark Case Registration Macros

MANAK_AUTO_GROUP_BENCHMARK_CASE_TIS

Create a benchmark case with name, tolerance, iterations and success percentage, and registers it automatically to the current group. Check out Tutorial on Using Groups for tutorial on advance group registration.

MANAK_AUTO_GROUP_BENCHMARK_CASE_TI

Create a benchmark case with name, tolerance and iterations, and registers it automatically to the current group. The value of success percentage is taken as default.

MANAK_AUTO_GROUP_BENCHMARK_CASE_IS

Create a benchmark case with name, iterations and success percentage, and registers it automatically to the current group. The value of tolerance is taken as default.

MANAK_AUTO_GROUP_BENCHMARK_CASE_I

Create a benchmark case with name and iterations, and registers it automatically to the current group. The values of tolerance and success percentage are taken as default.

MANAK_AUTO_GROUP_BENCHMARK_CASE_T

Create a benchmark case with name and tolerance, and registers it automatically to the current group. The values of iterations and success percentage are taken as default.

MANAK_AUTO_GROUP_BENCHMARK_CASE

Create a benchmark case with name, and registers it automatically to the current group. The values of tolerance, iterations and success percentage are taken as default.

For tutorial on manak group check out Tutorial on Using Groups

MANAK_ADD_TO_GROUP

Registers the given case to the current group.

Simple Module Auto Group Parametrized Benchmark Case Registration Macros

MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_TIS

Creates a parametrized benchmark case with name, function, tolerance, iterations and success percentage. Use 'MANAK_ADD_TO_GROUP' to register it to the current group.

{
}
void fun(size_t a)
{
}
MANAK_ADD_TO_GROUP(MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_TIS("ForLoops", fun, 1, 50, 90)->AddArgs(100));

MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_TI

Creates a parametrized benchmark case with name, function, tolerance and iterations. Use 'MANAK_ADD_TO_GROUP' to register it to the current group. The value of the success percentage is taken as default.

{
}
void fun(size_t a)
{
}

MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_IS

Creates a parametrized benchmark case with name, function, iterations and success percentage. Use 'MANAK_ADD_TO_GROUP' to register it to the current group. The value of tolerance is taken as default.

{
}
void fun(size_t a)
{
}

MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_I

Creates a parametrized benchmark case with name, function and iterations. Use 'MANAK_ADD_TO_GROUP' to register it to the current group. The values of tolerance and success percentage are taken as default.

{
}
void fun(size_t a)
{
}

MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_T

Creates a parametrized benchmark case with name, function and tolerance. Use 'MANAK_ADD_TO_GROUP' to register it to the current group. The values of iterations and success percentage are taken as default.

{
}
void fun(size_t a)
{
}

MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE

Creates a parametrized benchmark case with name and function. Use 'MANAK_ADD_TO_GROUP' to register it to the current group. The values of tolerance, iterations and success percentage are taken as default.

{
}
void fun(size_t a)
{
}

For example on simple module auto registration check Example.

Auto Registration With Normal Module

Simplest auto benchmark case registration -

#define MANAK_MODULE bench
#define MANAK_AUTO_MAIN
#define MANAK_INIT
#include <manak/manak.hpp>
{
Code;
}

Any auto registration registers the case or suite to the current suite. When no suite is set the current suite is set to master suite. So in the example above 'MANAK_AUTO_BENCHMARK_CASE' will register 'B1' to master suite.

When iteration, tolerance or success percentage is not specified for any benchmark case the default will be used. See MANAK_DEFAULT_ITERATIONS, MANAK_DEFAULT_TOLERANCE and MANAK_DEFAULT_SP for more details.

Normal Module Auto Case Registration Macros

MANAK_AUTO_BENCHMARK_CASE_TIS

Creates a benchmark case with name, library, tolerance, iterations and success percentage, and registers it under the current suite.

MANAK_AUTO_BENCHMARK_CASE_TIS(B1, Lib1, 10, 50, 90)
{
Code;
}

MANAK_AUTO_BENCHMARK_CASE_TI

Creates a benchmark case with name, library, tolerance and iterations, and registers it under the current suite. The success percentage is taken as the defaut value.

{
Code;
}

MANAK_AUTO_BENCHMARK_CASE_IS

Creates a benchmark case with name, iterations and success percentage, and registers it under the current suite. The tolerance is taken as the default value.

{
Code;
}

MANAK_AUTO_BENCHMARK_CASE_I

Creates benchmark case with name, library and iterations, and registers it to the current benchmark suite. The tolerance and success percenatge is taken as default.

{
Code;
}

MANAK_AUTO_BENCHMARK_CASE_T

Creates benchmark case with name, libray and tolerance, and registers it to the current benchmark suite. The value of iterations and success percentage is taken to be default.

{
Code;
}

MANAK_AUTO_BENCHMARK_CASE

Creates benchmark case with name, and registers it to the current benchmark suite. Iterations, tolerance and success percentage for the benchmark case are taken to be defaults.

MANAK_ADD_CASE

'MANAK_ADD_CASE' can be used to register manually generated benchmark case. This is especially useful when written function needs to be added as benchmark case.

#define MANAK_MODULE bench
#define MANAK_AUTO_MAIN
#define MANAK_INIT
#include <manak/manak.hpp>
int fun()
{
Code to benchmark;
}

'MANAK_BENCHMARK_CASE' is a directive for manual registration. For more such directives see Manual Registration.

The function to be registered must have no parameters. The function with parameters can used to generate parametrized benchmark cases. See Complete guide on Parametrized Benchmarking for more information. Also see Advance Function Registration for registration of complex functions such as overloaded functions, template functions and class member functions.

Normal Module Auto Suite Registration Macros

MANAK_AUTO_SUITE

Creates a new benchmarking suite with given name and registers it to the current benchmarking suite. It also sets the newly generated benchmarking suite as the current suite.

#define MANAK_MODULE bench
#define MANAK_AUTO_MAIN
#define MANAK_INIT
#include <manak/manak.hpp>
{
Code;
}

In the above example 'Suite1' will be registered under master suite and 'B1' will be registered under 'Suite1'.

MANAK_AUTO_SUITE_END

Sets the current benchmark suite to the parent of current of benchmark suite.

#define MANAK_MODULE bench
#define MANAK_AUTO_MAIN
#define MANAK_INIT
#include <manak/manak.hpp>
{
Code;
}
{
Code;
}

In the above example 'B1' will be registered under 'Suite1' but 'B2' will be registered under master suite.

Normal Module Auto Parametrized Benchmark Case Registration Macros

MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_TIS

Creates a parametrized benchmark case with name, function, tolerance, iterations and success percentage. To register use 'MANAK_ADD_CASE'.

int fun(size_t a)
{
(
for(size_t i = 0;i < a;i++);
)
}
MANAK_ADD_CASE(MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_TIS(ForLoops, Lib1, fun, 10 50, 90)->AddArgs(1000)->AddArgs(2000));

MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_TI

Creates a parametrized benchmark case with name, function, tolerance and iterations. To register use 'MANAK_ADD_CASE'. The value of success percentage is taken as constant.

int fun(size_t a)
{
(
for(size_t i = 0;i < a;i++);
)
}
MANAK_ADD_CASE(MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_TI(ForLoops, Lib1, fun)->AddArgs(1000)->AddArgs(2000));

MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_IS

Creates a parametrized benchmark case with name, function, iterations and success percentage. To register use 'MANAK_ADD_CASE'. The value of tolerance is taken as constant.

int fun(size_t a)
{
(
for(size_t i = 0;i < a;i++);
)
}
MANAK_ADD_CASE(MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_IS(ForLoops, Lib1, fun, 10, 90)->AddArgs(1000)->AddArgs(2000));

MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_I

Creates a parametrized benchmark case with name, function and iterations. To register use 'MANAK_ADD_CASE'. The values of tolerance and success percentage are taken as constant.

int fun(size_t a)
{
(
for(size_t i = 0;i < a;i++);
)
}
MANAK_ADD_CASE(MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_I(ForLoops, Lib1, fun, 10)->AddArgs(1000)->AddArgs(2000));

MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_T

Creates a parametrized benchmark case with name, function and tolerance. To register use 'MANAK_ADD_CASE'. The values of iterations and success percentage are taken as constant.

int fun(size_t a)
{
(
for(size_t i = 0;i < a;i++);
)
}
MANAK_ADD_CASE(MANAK_CREATE_BENCHMARK_WITH_TEMPLATE_I(ForLoops, Lib1, fun, 10)->AddArgs(1000)->AddArgs(2000));

MANAK_CREATE_BENCHMARK_WITH_TEMPLATE

Creates a parametrized benchmark case with name and function. To register use 'MANAK_ADD_CASE'. The values of tolerance, iterations and success percentage are taken as constant.

int fun(size_t a)
{
(
for(size_t i = 0;i < a;i++);
)
}
MANAK_ADD_CASE(MANAK_CREATE_BENCHMARK_WITH_TEMPLATE(ForLoops, Lib1, fun)->AddArgs(1000)->AddArgs(2000));

For more advance parametrized benchmark options check Complete guide on Parametrized Benchmarking.

Normal Module Auto Group Registration Macros

MANAK_AUTO_GROUP AND MANAK_AUTO_GROUP_END

'MANAK_AUTO_GROUP' starts a group and registers the cases inside to current suite.

MANAK_ADD_GROUP

Add the manually created group to current suite. Accepts first argument as the group name with complete template specialization. After this any number of argument can be passed which will be directed to initialization of the group.

MANAK_GROUP(TestGroup);
GINIT(size_t a, size_t b)
{
}
MANAK_ADD_GROUP(TestGroup, 10, 10);

Normal Module Auto Group Benchmark Case Registration Macros

MANAK_AUTO_GROUP_BENCHMARK_CASE_TIS

Create a benchmark case with name, tolerance, iterations and success percentage, and registers it automatically to the current group. Check out Tutorial on Using Groups for tutorial o advance group registration.

{
}
MANAK_AUTO_GROUP_BENCHMARK_CASE_TIS("ForLoops", "Lib1", 10, 50, 90)
{
}

MANAK_AUTO_GROUP_BENCHMARK_CASE_TI

Create a benchmark case with name, tolerance and iterations, and registers it automatically to the current group. The value of success percentage is taken as default.

{
}
MANAK_AUTO_GROUP_BENCHMARK_CASE_TI("ForLoops", "Lib1", 10, 50)
{
}

MANAK_AUTO_GROUP_BENCHMARK_CASE_IS

Create a benchmark case with name, iterations and success percentage, and registers it automatically to the current group. The value of tolerance is taken as default.

{
}
MANAK_AUTO_GROUP_BENCHMARK_CASE_IS("ForLoops", "Lib1", 10, 50)
{
}

MANAK_AUTO_GROUP_BENCHMARK_CASE_I

Create a benchmark case with name and iterations, and registers it automatically to the current group. The values of tolerance and success percentage are taken as default.

MANAK_AUTO_GROUP_BENCHMARK_CASE_T

Create a benchmark case with name and tolerance, and registers it automatically to the current group. The values of iterations and success percentage are taken as default.

MANAK_AUTO_GROUP_BENCHMARK_CASE

Create a benchmark case with name, and registers it automatically to the current group. The values of tolerance, iterations and success percentage are taken as default.

For tutorial on manak group check out Tutorial on Using Groups

MANAK_ADD_TO_GROUP

Registers the given case to the current group.

{
}
void fun()
{
}

Normal Module Auto Group Parametrized Benchmark Case Registration Macros

MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_TIS

Creates a parametrized benchmark case with name, function, tolerance, iterations and success percentage. Use 'MANAK_ADD_TO_GROUP' to register it to the current group.

{
}
void fun(size_t a)
{
}
MANAK_ADD_TO_GROUP(MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_TIS("ForLoops", "Lib1", fun, 1, 50, 90)->AddArgs(100));

MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_TI

Creates a parametrized benchmark case with name, function, tolerance and iterations. Use 'MANAK_ADD_TO_GROUP' to register it to the current group. The value of the success percentage is taken as default.

{
}
void fun(size_t a)
{
}
MANAK_ADD_TO_GROUP(MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_TI("ForLoops", "Lib1", fun, 1, 50)->AddArgs(100));

MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_IS

Creates a parametrized benchmark case with name, function, iterations and success percentage. Use 'MANAK_ADD_TO_GROUP' to register it to the current group. The value of tolerance is taken as default.

{
}
void fun(size_t a)
{
}
MANAK_ADD_TO_GROUP(MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_IS("ForLoops", "Lib1", fun, 1, 50)->AddArgs(100));

MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_I

Creates a parametrized benchmark case with name, function and iterations. Use 'MANAK_ADD_TO_GROUP' to register it to the current group. The values of tolerance and success percentage are taken as default.

{
}
void fun(size_t a)
{
}
MANAK_ADD_TO_GROUP(MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_I("ForLoops", "Lib1", fun, 1)->AddArgs(100));

MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_T

Creates a parametrized benchmark case with name, function and tolerance. Use 'MANAK_ADD_TO_GROUP' to register it to the current group. The values of iterations and success percentage are taken as default.

{
}
void fun(size_t a)
{
}
MANAK_ADD_TO_GROUP(MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE_T("ForLoops", "Lib1", fun, 1)->AddArgs(100));

MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE

Creates a parametrized benchmark case with name and function. Use 'MANAK_ADD_TO_GROUP' to register it to the current group. The values of tolerance, iterations and success percentage are taken as default.

{
}
void fun(size_t a)
{
}
MANAK_ADD_TO_GROUP(MANAK_CREATE_GROUP_BENCHMARK_WITH_TEMPLATE("ForLoops", "Lib1", fun)->AddArgs(100));

For example on normal module auto registration check Example.