Home > Back-end >  Use minitrace in a given namespace in C
Use minitrace in a given namespace in C

Time:08-11

I'm using minitrace to profile performance of my functions in a namesapce filtration. However, minitrace does not work if functions like MTR_BEGIN() are invoked inside a namespace. The following is my code. My idea is to add namesapce to minitrace.h. Any suggestion on having minitrace work in a namesapce?

#include "minitrace.h"

namesapce filtration {
    FILE* trace_file = fopen("/tmp/trace", "wb");
    mtr_init_from_stream(trace_file);
    MTR_META_PROCESS_NAME("minitrace_test");
    MTR_META_THREAD_NAME("main thread");
    int long_running_thing_1;
    int long_running_thing_2;
    MTR_START("background", "long_running", &long_running_thing_1);
    MTR_START("background", "long_running", &long_running_thing_2);
    MTR_BEGIN("main", "binary_search");

    binarySearch();

    MTR_END("main", "binary_search");
    MTR_FINISH("background", "long_running", &long_running_thing_1);
    MTR_FINISH("background", "long_running", &long_running_thing_2);
    mtr_flush();
    mtr_shutdown();
}

CodePudding user response:

I see some functions signature in minitrace.h. I think you can add namesapce like minitrace to these functions.

  • Related