{"id":19357708,"url":"https://github.com/joomla-framework/profiler","last_synced_at":"2025-07-26T03:07:13.517Z","repository":{"id":7094592,"uuid":"8385879","full_name":"joomla-framework/profiler","owner":"joomla-framework","description":"Joomla Framework Profiler Package","archived":false,"fork":false,"pushed_at":"2025-07-19T13:43:27.000Z","size":109,"stargazers_count":6,"open_issues_count":0,"forks_count":5,"subscribers_count":13,"default_branch":"3.x-dev","last_synced_at":"2025-07-19T17:43:39.697Z","etag":null,"topics":["joomla","joomla-framework","php","profiler"],"latest_commit_sha":null,"homepage":"https://framework.joomla.org/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joomla-framework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"joomla","custom":"https://community.joomla.org/sponsorship-campaigns.html"}},"created_at":"2013-02-24T03:32:38.000Z","updated_at":"2025-07-19T13:42:50.000Z","dependencies_parsed_at":"2024-12-10T08:19:29.376Z","dependency_job_id":"bf9a5219-9550-4aba-9bc3-4a7a9d870c06","html_url":"https://github.com/joomla-framework/profiler","commit_stats":{"total_commits":65,"total_committers":15,"mean_commits":4.333333333333333,"dds":0.6,"last_synced_commit":"ace5a4fa8fc50596b691106d47b0aa3d37975548"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/joomla-framework/profiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomla-framework%2Fprofiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomla-framework%2Fprofiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomla-framework%2Fprofiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomla-framework%2Fprofiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joomla-framework","download_url":"https://codeload.github.com/joomla-framework/profiler/tar.gz/refs/heads/3.x-dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomla-framework%2Fprofiler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266738658,"owners_count":23976439,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["joomla","joomla-framework","php","profiler"],"created_at":"2024-11-10T07:08:54.787Z","updated_at":"2025-07-26T03:07:13.502Z","avatar_url":"https://github.com/joomla-framework.png","language":"PHP","funding_links":["https://github.com/sponsors/joomla","https://community.joomla.org/sponsorship-campaigns.html"],"categories":[],"sub_categories":[],"readme":"## The Profiler Package [![Build Status](https://github.com/joomla-framework/profiler/actions/workflows/ci.yml/badge.svg?branch=3.x-dev)](https://github.com/joomla-framework/profiler)\n\n[![Latest Stable Version](https://poser.pugx.org/joomla/profiler/v/stable)](https://packagist.org/packages/joomla/profiler)\n[![Total Downloads](https://poser.pugx.org/joomla/profiler/downloads)](https://packagist.org/packages/joomla/profiler)\n[![Latest Unstable Version](https://poser.pugx.org/joomla/profiler/v/unstable)](https://packagist.org/packages/joomla/profiler)\n[![License](https://poser.pugx.org/joomla/profiler/license)](https://packagist.org/packages/joomla/profiler)\n\nThe Joomla Framework provides you a Profiler to profile the time that it takes to do certain tasks or reach various milestones as your extension runs.\n\n### Usage\n\n```php\nuse Joomla\\Profiler\\Profiler;\n\n// Creating a Profiler having the name \"Notes\".\n$profiler = new Profiler('Notes');\n\n// Mark a point called \"Start\".\n$profiler-\u003emark('Start');\n\n// Execute some code...\n\n// Mark a point called \"Middle\".\n$profiler-\u003emark('Middle');\n\n// Execute some code...\n\n// Mark a point called \"End\".\n$profiler-\u003emark('End');\n```\n\nYou must at least mark the first point which will be the reference.\n\nNow, you can retrieve the elapsed time between two points :\n\n```php\nuse Joomla\\Profiler\\Profiler;\n\n// Return the elapsed time in seconds between two points (the order does not matter).\n$elapsed = $profiler-\u003egetTimeBetween('Start', 'Middle');\n```\n\nYou can also retrieve the amount of allocated memory between two points.\n\n```php\nuse Joomla\\Profiler\\Profiler;\n\n// Return the amount of allocated memory between these two points.\n$elapsed = $profiler-\u003egetMemoryBytesBetween('Start', 'Middle');\n```\n\nWhen you have finished, you can output the result.\n\n```php\n// Will display the profiler results.\necho $profiler;\n\n// Will render the profiler as a string.\n$render = $profiler-\u003erender();\n```\n\nThe output could look something like the following:\n\n```\nNotes 0.000 seconds (+0.000); 0.00 MB (+0.000) - Start\nNotes 1.000 seconds (+1.000); 3.00 MB (+3.000) - Middle\nNotes 1.813 seconds (+0.813); 6.24 MB (+3.240) - End\n```\n\nYou can see each line is qualified by the name you used when creating your profiler, and then the names you used for the mark.\n\nThe start point (the first marked point) is the reference, and by consequence has a null time and memory usage.\n\nWe can see that the code executed between the \"Start\" and the \"Middle\" point took 1 second to perform and increased the memory usage by 3 Mega Bytes.\n\n## Writing your own Renderer\n\nYou can write your own renderer if you need an other formatting. In order to do so, you need to implement the ProfilerRendererInterface.\n\n```php\nnamespace MyApp;\n\nuse Joomla\\Profiler\\ProfilerRendererInterface;\nuse Joomla\\Profiler\\ProfilerInterface;\n\nclass MyRenderer implements ProfilerRendererInterface\n{\n\t/**\n\t * Renders a profiler.\n\t * We want to display the point names and the elapsed time in front of them.\n\t *\n\t * start : +0 seconds\n\t * middle : +x seconds\n\t * end : +y seconds.\n\t */\n\tpublic function render(ProfilerInterface $profiler)\n\t{\n\t\t// Prepare the string.\n\t\t$render = '';\n\n\t\t// Initialize a variable containing the last point.\n\t\t$lastPoint = null;\n\n\t\t// Get the points in the profiler.\n\t\t$points = $profiler-\u003egetPoints();\n\n\t\tforeach ($points as $point)\n\t\t{\n\t\t\t// Get the time of the last point (if any).\n\t\t\t$lastTime = $lastPoint ? $lastPoint-\u003egetTime() : 0;\n\n\t\t\t$render .= sprintf('%s: %f seconds.', $point-\u003egetName(), $point-\u003egetTime() - $lastTime);\n\t\t\t$render .= '\u003cbr/\u003e';\n\n\t\t\t$lastPoint = $point;\n\t\t}\n\n\t\treturn $render;\n\t}\n}\n```\n\nNow you can set your renderer in the Profiler :\n\n\n```php\n$profiler-\u003esetRenderer(new MyRenderer);\n\necho $profiler;\n```\n\nIt should output something like :\n\n```\nStart: 0.000000 seconds.\nMiddle: 0.000172 seconds.\nEnd: 0.000016 seconds.\n```\n\n## Installation via Composer\n\nAdd `\"joomla/profiler\": \"~3.0\"` to the require block in your composer.json and then run `composer install`.\n\n```json\n{\n\t\"require\": {\n\t\t\"joomla/profiler\": \"~3.0\"\n\t}\n}\n```\n\nAlternatively, you can simply run the following from the command line:\n\n```sh\ncomposer require joomla/profiler \"~3.0\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoomla-framework%2Fprofiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoomla-framework%2Fprofiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoomla-framework%2Fprofiler/lists"}