Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Use minitrace in a given namespace in C++

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();
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading