mco_perfmon_get_options

Retrieves the current runtime configuration of the Performance Monitor.

Prototype

    const mco_perf_options_t *mco_perfmon_get_options(void);

Arguments

void
No arguments.

Description

This function returns a pointer to the internal performance monitor options structure. The returned pointer is valid only after mco_perfmon_init() has been called successfully.

The structure is read-only. Applications must not modify the contents of the returned structure directly. To change settings, use mco_perfmon_set_options() with a copy of the values.

Return Value

const mco_perf_options_t *
Pointer to the current performance monitor options. The value is undefined if the Performance Monitor has not been initialized.

Example

    #define PERF_DATABASE_SEGMENT_SIZE (64 << 20)  /* 64 MB */

    int main(int argc, char* argv[])
    {
        MCO_RET rc;
        void *perf_memory;

        perf_memory = malloc(PERF_DATABASE_SEGMENT_SIZE);
        if (!perf_memory) {
            /* handle allocation error */
        }

        rc = mco_perfmon_init(perf_memory, PERF_DATABASE_SEGMENT_SIZE);
        if (rc != MCO_S_OK) { /* handle error */ }

        /* Get current options */
        const mco_perf_options_t *current_opts = mco_perfmon_get_options();
        if (current_opts) {
            printf("Monitoring enabled: %d\n", current_opts->enabled);
            printf("Sampling interval: %u ms\n", current_opts->monitor_interval_ms);
        }

        /* To modify options, make a copy and use set_options */
        mco_perf_options_t new_opts = *current_opts;
        new_opts.enabled = 0;
        mco_perfmon_set_options(&new_opts);

        rc = mco_perfmon_close();
        free(perf_memory);
        return 0;
    }

Files

Header file:
mcoperfmon.h
Source file:
mcoperf.c
Library:
libmcoperf.a