Manak  2.0.0
Setting Environment

Linkage Type

Manak can be used both with static linkage and dynamic linkage. The default is static linkage. To use Manak with dynamic linkage -

#include <iostream>
Set Manak environment;
#define MANAK_USE_DYN_LINK
#include <manak/manak.hpp>

With this you need to provide the shared object generated in build to the linker. If you have installed Manak to one of the default directories, passing option '-lmanak' should work.

Set main function type

MANAK_AUTO_MAIN

By defining 'MANAK_AUTO_MAIN', manak will create a main function for you. This main function will initialize all the cases and run them.

Manually creating main function

You can create your own main function and still run all the benchmarks by calling function manak::manak_main. You can pass command line arguments to this function.

#define MANAK_SIMPLE_MODULE bench
#define MANAK_INIT
#include <manak/manak.hpp>
int main(int argc, char* argv[])
{
manak::manak_main(argc, argv);
}

NOTE: 'MANAK_AUTO_MAIN' or 'MANAK_INIT' has to be defined only once in case of multi file project. Check out Using Manak Effectively in Multi File Project for more information.

Set Manual initialization function

The deafult initialization function is manak::manak_init_module. This initialization function set all the primary environment variables. To register benchmarking cases manually you need to create and register your own benchmark initialization function. This can be done by setting MANAK_MANUAL_INIT_FUNCTION to the desired name. The initialization function should return bool, the success state. This function should be available in the namespace at the time 'manak_init_function' is defined. This manual init function will be called default init function.

bool bench_init();
#define MANAK_SIMPLE_MODULE bench
#define MANAK_AUTO_MAIN
#define MANAK_INIT
#define MANAK_MANUAL_INIT_FUNCTION bench_init
#include <manak/manak.hpp>
bool bench_init()
{
Manual case registration;
return true;
}

NOTE: 'MANAK_AUTO_MAIN' or 'MANAK_INIT' has to be defined only once in case of multi file project. Check out Using Manak Effectively in Multi File Project for more information.

For guide on manual case registration check out Manual Registration

Set Output Options

Setting Redirection Options

All the output to the standard output is redirected to predefined redirection stream while running any case. By default this redirection is done to file 'benchmark_log.txt'. To chnage the filename of of this default redirection file set 'MANAK_REDIRECTION_FILENAME' to desired value.

#define MANAK_SIMPLE_MODULE bench
#define MANAK_AUTO_BENCHMARK_MAIN
#define MANAK_INIT
#define MANAK_REDIRECTION_FILENAME logs.txt
#include <manak/manak.hpp>

Redirection can also be done to the already existing stream. Set 'MANAK_REDIRECTION_BUFFER' to stream's buffer.

#define MANAK_SIMPLE_MODULE bench
#define MANAK_AUTO_MAIN
#define MANAK_INIT
#define MANAK_REDIRECTION_BUFFER std::cout.rdbuf()
#include <manak/manak.hpp>

Setting Options For Output File

By default the results of the benchmarks are saved to file 'benchmark_stat.html'. This default filename can be changed by setting 'MANAK_DEFAULT_OUT_FILENAME' to desired value.

#define MANAK_SIMPLE_MODULE bench
#define MANAK_AUTO_MAIN
#define MANAK_INIT
#define MANAK_DEFAULT_OUT_FILENAME out
#include <manak/manak.hpp>

Here depending on the format the output will be either written to out.html or out.txt. The default format is HTML. The format can be changed with '-f' command line option. '-f TXT' will store the output i TXT format.

The output filname can also be given at runtime with command line argument '-o <filename>'. This run time filename will override the default filename. For more command line arguments

See Also
build_cli.

Other Environment Variables

MANAK_BASE_LIBRARY_NAME

Set MANAK_BASE_LIBRARY_NAME to desired name to change the name of singleton library in 'MANAK_SIMPLE_MODULE'.

#define MANAK_BASE_LIBRARY_NAME <name>

MANAK_DEFAULT_ITERATIONS

If number of iterations is not specified for any benchmark case the default number of iterations are used(which is 10). The default can be chnaged by setting 'MANAK_DEFAULT_ITERATIONS' to the desired value. The scope of this macro is limited by file, hence you can set different defaults for each file in your multi file project. Check out Using Manak Effectively in Multi File Project for tutorial on using Manak in multi file environment.

#define MANAK_DEFAULT_ITERATIONS <value in integer>

MANAK_DEFAULT_TOLERANCE

If tolerance is not specified for any benchmark case the default is used(which is 10ms). The default can be chnaged by setting 'MANAK_DEFAULT_TOLERANCE' to desired value. The measure of tolerance is microseconds. To understand the use of tolerance see Comparison Framework. The scope of this macro is limited by file, hence you can set different defaults for each file in your multi file project. Check out Using Manak Effectively in Multi File Project for tutorial on using Manak in multi file environment.

#define MANAK_DEFAULT_TOLERANCE <value in microseconds>

MANAK_DEFAULT_SP

If success percentage is not specified for any benchmark case the default is used(which is 100). The default can be chnaged by setting 'MANAK_DEFAULT_SP' to desired value. The scope of this macro is limited by file, hence you can set different defaults for each file in your multi file project. Check out Using Manak Effectively in Multi File Project for tutorial on using Manak in multi file environment.

#define MANAK_DEFAULT_SP <value in percentage>