{"id":13828245,"url":"https://github.com/badoo/liveprof","last_synced_at":"2025-10-05T13:14:45.113Z","repository":{"id":33981046,"uuid":"165101759","full_name":"badoo/liveprof","owner":"badoo","description":"A performance monitoring system for running on live sites","archived":false,"fork":false,"pushed_at":"2023-04-07T08:43:01.000Z","size":75,"stargazers_count":233,"open_issues_count":9,"forks_count":23,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-24T06:09:47.395Z","etag":null,"topics":["performance","php","profiler","tideways","xhprof"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/badoo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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":"2019-01-10T17:24:05.000Z","updated_at":"2025-05-23T12:11:58.000Z","dependencies_parsed_at":"2024-06-19T03:25:02.234Z","dependency_job_id":"ff440034-cc7d-4826-89a1-623bf6ab0dc0","html_url":"https://github.com/badoo/liveprof","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/badoo/liveprof","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badoo%2Fliveprof","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badoo%2Fliveprof/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badoo%2Fliveprof/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badoo%2Fliveprof/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/badoo","download_url":"https://codeload.github.com/badoo/liveprof/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badoo%2Fliveprof/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278459389,"owners_count":25990338,"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-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["performance","php","profiler","tideways","xhprof"],"created_at":"2024-08-04T09:02:38.174Z","updated_at":"2025-10-05T13:14:45.089Z","avatar_url":"https://github.com/badoo.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"Live Profiler\n================\n\n![logo](images/liveprof_logo.png \"logo\")\n\nLive Profiler is a system-wide performance monitoring system in use at Badoo that is built on top of [XHProf](http://pecl.php.net/package/xhprof) or its forks ([Uprofiler](https://github.com/FriendsOfPHP/uprofiler) or [Tideways](https://github.com/tideways/php-profiler-extension)).\nLive Profiler continually gathers function-level profiler data from production tier by running a sample of page requests under XHProf.\n\n[Live profiler UI](https://github.com/badoo/liveprof-ui) then aggregates the profile data corresponding to individual requests by various dimensions such a time, page type, and can help answer a variety of questions such as:\nWhat is the function-level profile for a specific page?\nHow expensive is function \"foo\" across all pages, or on a specific page?\nWhat functions regressed most in the last day/week/month?\nWhat is the historical trend for execution time of a page/function? and so on.\n\nHere is [a plugin](https://plugins.jetbrains.com/plugin/13767-live-profiler) for PhpStorm to see the method performance directly in IDE.\n\n[liveprof.org](http://liveprof.org/) shows all features and can be used for test purposes.\n\n[![Build Status](https://travis-ci.org/badoo/liveprof.svg?branch=master)](https://travis-ci.org/badoo/liveprof)\n[![codecov](https://codecov.io/gh/badoo/liveprof/branch/master/graph/badge.svg)](https://codecov.io/gh/badoo/liveprof)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/badoo/liveprof/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/badoo/liveprof/?branch=master)\n[![GitHub license](https://img.shields.io/github/license/badoo/liveprof.svg)](https://github.com/badoo/liveprof/blob/master/LICENSE)\n\nSystem Requirements\n===================\n\n* PHP version 5.4 or later / hhvm version 3.25.0 or later\n* One of [XHProf](http://pecl.php.net/package/xhprof),\n     [Uprofiler](https://github.com/FriendsOfPHP/uprofiler) or\n     [Tideways](https://github.com/tideways/php-profiler-extension) to profile and collect the data.\n  You can use other profiler which returns data in the follow format:\n  ```php\n  $data = [\n      [\n          'parent_method==\u003echild_method' =\u003e [\n              'param' =\u003e 'value' \n          ]\n      ]  \n  ];\n  ```  \n* Database extension to save profiling results to the database.\n\nInstallation\n============\n\n1. You can install Live Profiler via [Composer](https://getcomposer.org/):\n\n```bash\nphp composer.phar require badoo/liveprof\n```\n\n2. Prepere a storage for results depends on mode\n\n[save data in database] If you use DB mode you need to prepare a database server. You can use any driver described [here](https://www.doctrine-project.org/projects/doctrine-dbal/en/2.8/reference/configuration.html#configuration) or implement the custom one. You need run a script to configure database. This script creates \"details\" table: \n\n```bash\nLIVE_PROFILER_CONNECTION_URL=mysql://db_user:db_password@db_mysql:3306/Profiler?charset=utf8 php vendor/badoo/liveprof/bin/install.php\n```\n\n[save data in files] It's also possible to save profiling result into files. To do it prepare a directory with write permissions.\n\n[send data to demo site] You need to visit [liveprof.org](http://liveprof.org/) , sign in and copy API key.\n\n3. Init a profiler before working code in the project entry point (usually public/index.php).\n\nUsage\n=====\n\nThere is an example of usage a profiler with default parameters:\n```php\n\u003c?php\ninclude 'vendor/autoload.php';\n\n\\Badoo\\LiveProfiler\\LiveProfiler::getInstance()-\u003estart();\n// Code is here\n```\n\nThere is an example how to test Live Profiler without any extension and database. You can use a build-in profiler compatible with XHProf and \u003ca href=\"http://liveprof.org\"\u003eliveprof.org\u003c/a\u003e as UI:\n```php\n\u003c?php\ninclude 'vendor/autoload.php';\n\n\\Badoo\\LiveProfiler\\LiveProfiler::getInstance()\n     -\u003esetMode(\\Badoo\\LiveProfiler\\LiveProfiler::MODE_API)\n     -\u003esetApiKey('70366397-97d6-41be-a83c-e9e649c824e1') // a key for guest\n     -\u003euseSimpleProfiler() // Use build-in profiler instead of XHProf or its forks\n     -\u003esetApp('Demo') // Some unique app name\n     -\u003estart();\n     \n// Code is here\n// start a timer before each inportant method\n\\Badoo\\LiveProfiler\\SimpleProfiler::getInstance()-\u003estartTimer(__METHOD__); // any string can be used as a timer tag\n// stop the timer before the end of the method\n\\Badoo\\LiveProfiler\\SimpleProfiler::getInstance()-\u003eendTimer(__METHOD__); // any string can be used as a timer tag\n```\n\nThere is a full list of methods you can use to change options:\n```php\n\u003c?php\n\n// Start profiling\n\\Badoo\\LiveProfiler\\LiveProfiler::getInstance()\n    -\u003esetMode(\\Badoo\\LiveProfiler\\LiveProfiler::MODE_DB) // optional, MODE_DB - save profiles to db, MODE_FILES - save profiles to files, MODE_API - send profiles to http://liveprof.org/ \n    -\u003esetConnectionString('mysql://db_user:db_password@db_mysql:3306/Profiler?charset=utf8') // optional, you can also set the connection url in the environment variable LIVE_PROFILER_CONNECTION_URL\n    -\u003esetPath('/app/data/') // optional, path to save profiles, you can also set the file path in the environment variable LIVE_PROFILER_PATH\n    -\u003esetApiKey('api_key') // optional, api key to send profiles and see demo, you can get it on http://liveprof.org/ \n    -\u003esetApp('Site1') // optional, current app name to use one profiler in several apps, \"Default\" by default\n    -\u003esetLabel('users') // optional, the request name, by default the url path or script name in cli\n    -\u003esetDivider(700) // optional, profiling starts for 1 of 700 requests with the same app and label, 1000 by default\n    -\u003esetTotalDivider(7000) // optional, profiling starts for 1 of 7000 requests with forces label \"All\", 10000 by default\n    -\u003esetLogger($Logger) // optional, a custom logger implemented \\Psr\\Log\\LoggerInterface\n    -\u003esetConnection($Connection) // optional, a custom instance of \\Doctrine\\DBAL\\Connection if you can't use the connection url\n    -\u003esetDataPacker($DatePacker) // optional, a class implemented \\Badoo\\LiveProfiler\\DataPackerInterface to convert array into string\n    -\u003esetStartCallback($profiler_start_callback) // optional, set it if you use custom profiler\n    -\u003esetEndCallback($profiler_profiler_callback) // optional, set it if you use custom profiler\n    -\u003euseXhprof() // optional, force use xhprof as profiler\n    -\u003euseTidyWays() // optional, force use TidyWays as profiler\n    -\u003euseUprofiler() // optional, force use uprofiler as profiler\n    -\u003euseSimpleProfiler() // optional, force use internal profiler\n    -\u003euseXhprofSample() // optional, force use xhprof in sampling mode\n    -\u003estart();\n```\n\nIf you want to change the Label during running (for instance, after you got some information in the router or controller) you can call:\n```php\n\u003c?php\n\n$number = random_int(0, 100);\n$current_label = \\Badoo\\LiveProfiler\\LiveProfiler::getInstance()-\u003egetLabel();\n\\Badoo\\LiveProfiler\\LiveProfiler::getInstance()-\u003esetLabel($current_label . $number);\n```\n\nif you don't want to save profiling result you can reset it anytime:\n```php\n\u003c?php\n\n\\Badoo\\LiveProfiler\\LiveProfiler::getInstance()-\u003ereset();\n```\n\nAfter script ends it will call `\\Badoo\\LiveProfiler\\LiveProfiler::getInstance()-\u003eend();` on shutdown, but you can call it explicitly after working code.\n\nEnvironment Variables\n=====================\n\n`LIVE_PROFILER_CONNECTION_URL`: [url](https://www.doctrine-project.org/projects/doctrine-dbal/en/2.8/reference/configuration.html#configuration) for the database connection\n\n`LIVE_PROFILER_PATH`: path to save profiles in \\Badoo\\LiveProfiler\\LiveProfiler::MODE_FILES mode\n\n`LIVE_PROFILER_API_URL`: api url to send profiles in \\Badoo\\LiveProfiler\\LiveProfiler::MODE_API mode and see demo on [liveprof.org](http://liveprof.org/) \n\nWork flow\n=========\n\nLive profiler allows to run profiling with custom frequency (for instance 1 of 1000 requests) grouped by app name ('Default' by default) and custom label (by default it's the url path or script name).\n\nIt's important to calculate **the request divider** properly to have enough data for aggregation. You should divide daily request count to have approximately 1 profile per minute.\nFor instance, if you have 1M requests a day for the page /users the divider should be 1000000/(60*24) = 694, so divider = 700 is enough.\n\nAlso you have to calculate **a total divider** for all request profiling. It's important to control the whole system health. It can be calculated the same way as a divider calculation for particularly request,\nbut in this case you should use count of all daily requests. For instance, if you have 10M requests a day - total_divider=10000000/(60*24) = 6940, so total_divider = 7000 is enough.\n\nThe profiler automatically detects which profiler extension you have (xhprof, uprofiler or tidyways). You have to set profiler callbacks if you use other profiler.\n\nYou can run the test script in the docker container with **xhprof** extension and look at the example of the server configuration in Dockerfile:\n```bash \ndocker build -t badoo/liveprof .\ndocker run badoo/liveprof\n```\n\nor you can build a docker container with **xhprof** using sampling:\n```bash \ndocker build -f DockerfileSamples -t badoo/liveprof .\ndocker run badoo/liveprof\n```\n\nor you can build a docker container with **tideways** extension:\n```bash \ndocker build -f DockerfileTidyWays -t badoo/liveprof .\ndocker run badoo/liveprof\n```\n\nor **uprofiler** extension:\n```bash \ndocker build -f DockerfileUprofiler -t badoo/liveprof .\ndocker run badoo/liveprof\n```\n\nor latest hhvm with included  **xhprof** extension:\n```bash\ndocker build -f DockerfileHHVM -t badoo/liveprof .\ndocker run badoo/liveprof\n```\nor if you want to use API with included  **xhprof** extension:\n```bash\ndocker build -f DockerfileUseApi -t badoo/liveprof .\ndocker run badoo/liveprof\n```\n\nIf your server has php version 7.0 or later it's better to use [Tideways](https://github.com/tideways/php-profiler-extension) as profiler.\n\nSteps to install tideways extension:\n```bash\ngit clone https://github.com/tideways/php-profiler-extension.git\ncd php-profiler-extension\nphpize\n./configure\nmake\nmake install\necho \"extension=tideways_xhprof.so\" \u003e\u003e /usr/local/etc/php/conf.d/20-tideways_xhprof.ini\necho \"xhprof.output_dir='/tmp/xhprof'\" \u003e\u003e /usr/local/etc/php/conf.d/20-tideways_xhprof.ini\n```\n\nSteps to install uprofiler:\n```bash\ngit clone https://github.com/FriendsOfPHP/uprofiler.git\ncd uprofiler/extension/\nphpize\n./configure\nmake\nmake install\necho \"extension=uprofiler.so\" \u003e\u003e /usr/local/etc/php/conf.d/20-uprofiler.ini\necho \"uprofiler.output_dir='/tmp/uprofiler'\" \u003e\u003e /usr/local/etc/php/conf.d/20-uprofiler.ini\n```\n\nTests\n=====\n\nInstall Live Profiler with dev requirements:\n```bash \nphp composer.phar require --dev badoo/liveprof\n```\n\nIn the project directory, run:\n```bash\nvendor/bin/phpunit\n```\n\nLicense\n=======\n\nThis project is licensed under the MIT open source license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadoo%2Fliveprof","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadoo%2Fliveprof","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadoo%2Fliveprof/lists"}