# &develguide;

The benchmark module provides an internal API to be used by other &osips; modules. The available functions are identical to the user exported functions.

Please note that this module is intended mainly for developers. It should be used with caution in production environments.

## Available Functions

### `bm_register(name, mode, id)`

This function register a new timer and/or returns the internal ID associated with the timer. mode controls the creation of new timer if not found. id is to be used by start and log timer functions.

### `bm_start(id)`

This function equals the user-exported function bm_start_timer. The id is passed as an integer, though.

### `bm_log(id)`

This function equals the user-exported function bm_log_timer. The id is passed as an integer, though.

## Benchmark API Example

### Using the benchmark module's API from another module

    ...
    #include "../benchmark/benchmark.h"
    ...
    struct bm_binds bmb;
    ...
    ...
    /* load the benchmarking API */
    if (load_bm_api( &bmb )!=0) {
        LM_ERR("can't load benchmark API\n");
        goto error;
    }
    ...
    ...
    /* Start/log timers during a (usually user-exported) module function */
    bmb.bm_register("test", 1, &id)
    bmb.bm_start(id);
    do_something();
    bmb.bm_log(id);
    ...