{"id":28999977,"url":"https://github.com/ripred/profiler","last_synced_at":"2025-06-25T08:41:15.374Z","repository":{"id":186430859,"uuid":"675162237","full_name":"ripred/Profiler","owner":"ripred","description":"Easily profile your Arduino functions to see how much time they take. The output can be disabled and enabled at runtime. Very lightweight. Optional output pin debugging and custom text output supported too.","archived":false,"fork":false,"pushed_at":"2024-08-22T09:12:02.000Z","size":66,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-23T10:10:37.937Z","etag":null,"topics":["arduino","arduino-library","cplusplus","cpp","profiling","profiling-library","utility-library"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ripred.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-06T02:00:29.000Z","updated_at":"2024-08-22T09:12:05.000Z","dependencies_parsed_at":"2024-08-22T10:06:13.254Z","dependency_job_id":null,"html_url":"https://github.com/ripred/Profiler","commit_stats":null,"previous_names":["ripred/profiler"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/ripred/Profiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FProfiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FProfiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FProfiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FProfiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ripred","download_url":"https://codeload.github.com/ripred/Profiler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FProfiler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261838335,"owners_count":23217616,"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":["arduino","arduino-library","cplusplus","cpp","profiling","profiling-library","utility-library"],"created_at":"2025-06-25T08:41:14.199Z","updated_at":"2025-06-25T08:41:15.365Z","avatar_url":"https://github.com/ripred.png","language":"C++","readme":"\u003c!-- [![Arduino CI](https://github.com/ripred/Profiler/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) --\u003e\n[![Arduino-lint](https://github.com/ripred/Profiler/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/ripred/Profiler/actions/workflows/arduino-lint.yml)\n![code size:](https://img.shields.io/github/languages/code-size/ripred/Profiler)\n[![GitHub release](https://img.shields.io/github/release/ripred/Profiler.svg?maxAge=3600)](https://github.com/ripred/Profiler/releases)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ripred/Profiler/blob/master/LICENSE)\n\n\n# Profiler\nEasily profile your Arduino functions (or even just a few lines of code) to see how much time they take, simply by declaring a `profiler_t` variable anywhere in your code. \n\nAs soon as that variable goes out of scope it automatically outputs the amount of time it existed, to any serial output path or device you specify. The output can be disabled and enabled at any time. Very lightweight. \n\nThe destination for the output over serial can be optionally specified and you can use any Arduino platform `Stream` subclass. This includes `Serial1` or `Serial2` on boards that have them, and even instances of `SoftwareSerial`, which is also `Stream` compatible. 😄 If not specified in the variable's construction then the default is the standard `Serial` device.\n\nSeveral useful constructor types define the features that are used at runtime.\n\nUpdated: Now includes support for optional custom text 😎\n\n```cpp\n/*\n * Profiler.ino\n *\n * Example Arduino sketch for the Arduino Profiler library\n *\n * version 1.0 - August 2023 ++trent m. wyatt\n * version 1.1 - October 2023\n *    added optional debug pin support\n * version 1.6 - August 2024\n *    added optional custom output text support\n *\n * The available constructors are:\n *\n *    profiler_t(Stream \u0026s = Serial);\n *    profiler_t(int pin, Stream \u0026s = Serial);\n *    profiler_t(char const * const msg, Stream \u0026s = Serial);\n *    profiler_t(int pin, char const * const msg, Stream \u0026s = Serial);\n * \n */\n\n#include \u003cProfiler.h\u003e\n\n#define   DEBUG_LED   13\n\n// forward declarations (function prototypes):\nvoid foo();\nvoid bar();\nvoid baz();\n\nvoid setup() {\n    Serial.begin(115200);\n    while (!Serial);\n\n    foo();\n    bar();\n    baz();\n}\n\nvoid loop() {\n\n}\n\n\n// Example function that will be profiled including debug pin output:\n// (the debug output pin is HIGH for one second in this example usage)\nvoid foo() {\n    profiler_t profiler(DEBUG_LED);\n\n    // ... some other code you want profiled\n    delay(1000);\n}\n\n// Example function where only a smaller part of the code\n// will be profiled using a temporary scope. Also makes use \n// of the new custom output text support:\n//\nvoid bar() {\n    // this code will NOT be profiled.\n    // yes the code is pointless heh\n    for (int i=0; i \u003c 10; i++) {\n        delay(100);\n    }\n\n    // create a temporary scope just to contain the instantiation of a profiler_t\n    // object in order to time a smaller section of code inside a larger section\n    // and customize the output text:\n    {\n        profiler_t profiler(\"Partial Scoped Profile\");\n        \n        // ... some other code you want profiled\n        delay(500);\n    }\n\n    // more pointless code that will NOT be profiled\n    for (int i=0; i \u003c 10; i++) {\n        delay(100);\n    }\n}\n\n// Example function that will be profiled and use customized text output\n// to automatically include the enclosing function name, so you can reuse \n// this same code in many functions and it will automatically output each\n// function's correct name:\n//\nvoid baz() {\n    profiler_t profiler(\n        (String(\"Time spent in \") + \n        String(__FUNCTION__) + \n        String(\"()\")).c_str());\n\n    // ... some other code you want profiled\n    delay(2000);\n}\n```\n\noutput:\n\n```console\nTime Spent: 999\nPartial Scoped Profile: 500\nTime spent in baz(): 1999\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fripred%2Fprofiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fripred%2Fprofiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fripred%2Fprofiler/lists"}