{"id":13420601,"url":"https://github.com/CedricGuillemet/libProfiler","last_synced_at":"2025-03-15T07:31:15.411Z","repository":{"id":6069059,"uuid":"7294955","full_name":"CedricGuillemet/libProfiler","owner":"CedricGuillemet","description":"Profile your c++ code ","archived":false,"fork":false,"pushed_at":"2012-12-23T13:26:03.000Z","size":127,"stargazers_count":80,"open_issues_count":0,"forks_count":16,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-07-31T22:56:03.060Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CedricGuillemet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-23T13:00:15.000Z","updated_at":"2024-04-14T13:17:15.000Z","dependencies_parsed_at":"2022-09-12T13:21:17.882Z","dependency_job_id":null,"html_url":"https://github.com/CedricGuillemet/libProfiler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CedricGuillemet%2FlibProfiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CedricGuillemet%2FlibProfiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CedricGuillemet%2FlibProfiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CedricGuillemet%2FlibProfiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CedricGuillemet","download_url":"https://codeload.github.com/CedricGuillemet/libProfiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243701005,"owners_count":20333614,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T22:01:37.131Z","updated_at":"2025-03-15T07:31:15.069Z","avatar_url":"https://github.com/CedricGuillemet.png","language":"C","funding_links":[],"categories":["TODO scan for Android support in followings","C++"],"sub_categories":[],"readme":"libProfiler\n===========\n\n\nlibProfiler is a tool to measure time taken by a code portion. It can help you improve code performance.\nIt can be easily integrated in your toolchain, continuous integration,...\nIt's implemented as only one multiplatform and threadsafe C++ header file! It works on Windows, Linux and MacOSX.\nAs you define the granularity, it may be more usefull than great tools like Verysleepy. And it\nworks well with debug info turned off and full optmisation turned on.\nSadly, it uses STL (nobody's perfect)\n\nHow to use it:\n\nInclude this header. For one of .cpp where it's included add:\n\n    #define LIB_PROFILER_IMPLEMENTATION\n\nIn your project preprocessor, define USE_PROFILER. If USE_PROFILER is not defined, every\nlibProfiler macro is defined empty. So depending on your project target, you can enable/disable\nprofiling.\n\nLet's see an example code :\n\n\n    #include \u003ciostream\u003e\n    #include \u003cmath.h\u003e\n    \n    void myPrintf( const char *szText )\n    {\n    \tprintf(\"Profiler:%s\", szText);\n    }\n\n\n    #define USE_PROFILER 1\n    #define LIB_PROFILER_IMPLEMENTATION\n    #define LIB_PROFILER_PRINTF myPrintf\n    #include \"libProfiler.h\"\n    \n    \n    void myFunction()\n    {\n        PROFILER_START(myFunction);\n        float v = 0;\n        for(int i = 0;i\u003c1000000;i++)\n            v += cosf(static_cast\u003cfloat\u003e(rand()));\n    \n        printf(\"v = %5.4f\\n\", v);\n        PROFILER_END();\n    }\n    \n    int main(int argc, const char * argv[])\n    {\n        PROFILER_ENABLE;\n    \n        PROFILER_START(Main);\n    \n        std::cout \u003c\u003c \"Hello, World!\\n\";\n        myFunction();\n        myFunction();\n    \n        PROFILER_END();\n    \n        LogProfiler();\n    \n        PROFILER_DISABLE;\n    \n        return 0;\n    }\n\n\nEnable/disable profiling with USE_PROFILER.\nIn one of your .cpp file, define LIB_PROFILER_IMPLEMENTATION or you'll have troubles linking.\nYou can overide the default printf output redefining preprocessor LIB_PROFILER_PRINTF.\nThe sample will output:\n\n\n    Hello, World!\n    v = -1530.3564\n    v = -190.7513\n    Profiler:CALLSTACK of Thread 0\n    Profiler:_______________________________________________________________________________________\n    Profiler:| Total time   | Avg Time     |  Min time    |  Max time    | Calls  | Section\n    Profiler:_______________________________________________________________________________________\n    Profiler:|      79.0000 |      79.0000 |      79.0000 |      79.0000 |     1  | Main\n    Profiler:|      79.0000 |      39.5000 |      38.0000 |      41.0000 |     2  |   myFunction\n    Profiler:_______________________________________________________________________________________\n    \n    Profiler:\n    \n    Profiler:DUMP of Thread 0\n    Profiler:_______________________________________________________________________________________\n    Profiler:| Total time   | Avg Time     |  Min time    |  Max time    | Calls  | Section\n    Profiler:_______________________________________________________________________________________\n    Profiler:|      79.0000 |      79.0000 |      79.0000 |      79.0000 |      1 | Main\n    Profiler:|      79.0000 |      39.5000 |      38.0000 |      41.0000 |      2 | myFunction\n    Profiler:_______________________________________________________________________________________\n\n\n\nThe first list correspond to the callstack ( with left spaced function name). You might see a\na profiled block multiple time depending on where it was called.\nThe second list is a flat one. Profiled block only appear once.\nTime unit is ms.\n    \nThis text is also present in libProfiler.h\n\nThis has been possible thank to the work of Christophe Giraud and Maxime Houlier.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCedricGuillemet%2FlibProfiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCedricGuillemet%2FlibProfiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCedricGuillemet%2FlibProfiler/lists"}