{"id":24438426,"url":"https://github.com/wp-cli/profile-command","last_synced_at":"2025-05-14T21:09:21.376Z","repository":{"id":45120168,"uuid":"64142089","full_name":"wp-cli/profile-command","owner":"wp-cli","description":"Quickly identify what's slow with WordPress","archived":false,"fork":false,"pushed_at":"2024-11-25T08:38:32.000Z","size":355,"stargazers_count":274,"open_issues_count":16,"forks_count":28,"subscribers_count":19,"default_branch":"main","last_synced_at":"2025-04-01T07:40:07.011Z","etag":null,"topics":["bottleneck","cli","hacktoberfest","measure","performance","profile","wordpress","wp-cli","wp-cli-package"],"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/wp-cli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-25T14:37:50.000Z","updated_at":"2025-04-01T04:48:42.000Z","dependencies_parsed_at":"2024-06-18T15:33:40.793Z","dependency_job_id":"0dd0333a-4548-4b13-b5bf-d7fc89d9f4ef","html_url":"https://github.com/wp-cli/profile-command","commit_stats":{"total_commits":275,"total_committers":16,"mean_commits":17.1875,"dds":0.4290909090909091,"last_synced_commit":"04c20f23da4f04bf5ff880207e96a0e5cf3ad90a"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-cli%2Fprofile-command","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-cli%2Fprofile-command/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-cli%2Fprofile-command/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-cli%2Fprofile-command/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wp-cli","download_url":"https://codeload.github.com/wp-cli/profile-command/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247801155,"owners_count":20998338,"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":["bottleneck","cli","hacktoberfest","measure","performance","profile","wordpress","wp-cli","wp-cli-package"],"created_at":"2025-01-20T19:16:15.340Z","updated_at":"2025-04-08T08:10:49.137Z","avatar_url":"https://github.com/wp-cli.png","language":"PHP","readme":"wp-cli/profile-command\n======================\n\nQuickly identify what's slow with WordPress.\n\n[![Testing](https://github.com/wp-cli/profile-command/actions/workflows/testing.yml/badge.svg)](https://github.com/wp-cli/profile-command/actions/workflows/testing.yml)\n\nQuick links: [Overview](#overview) | [Using](#using) | [Installing](#installing) | [Contributing](#contributing)\n\n## Overview\n\n`wp profile` monitors key performance indicators of the WordPress execution process to help you quickly identify points of slowness.\n\nSave hours diagnosing slow WordPress sites. Because you can easily run it on any server that supports WP-CLI, `wp profile` compliments Xdebug and New Relic by pointing you in the right direction for further debugging. Because it runs on the command line, using `wp profile` means you don't have to install a plugin and deal with the painful dashboard of a slow WordPress site. And, because it's a WP-CLI command, `wp profile` makes it easy to perform hard tasks (e.g. [profiling a WP REST API response](https://danielbachhuber.com/tip/profile-wp-rest-api/)).\n\n[Identify why WordPress is slow in just a few steps](https://danielbachhuber.com/tip/identify-wordpress-slowness/) with `wp profile`.\n\n## Using\n\nThis package implements the following commands:\n\n### wp profile stage\n\nProfile each stage of the WordPress load process (bootstrap, main_query, template).\n\n~~~\nwp profile stage [\u003cstage\u003e] [--all] [--spotlight] [--url=\u003curl\u003e] [--fields=\u003cfields\u003e] [--format=\u003cformat\u003e] [--order=\u003corder\u003e] [--orderby=\u003cfields\u003e]\n~~~\n\nWhen WordPress handles a request from a browser, it’s essentially\nexecuting as one long PHP script. `wp profile stage` breaks the script\ninto three stages:\n\n* **bootstrap** is where WordPress is setting itself up, loading plugins\nand the main theme, and firing the `init` hook.\n* **main_query** is how WordPress transforms the request (e.g. `/2016/10/21/moms-birthday/`)\ninto the primary WP_Query.\n* **template** is where WordPress determines which theme template to\nrender based on the main query, and renders it.\n\n**OPTIONS**\n\n\t[\u003cstage\u003e]\n\t\tDrill down into a specific stage.\n\n\t[--all]\n\t\tExpand upon all stages.\n\n\t[--spotlight]\n\t\tFilter out logs with zero-ish values from the set.\n\n\t[--url=\u003curl\u003e]\n\t\tExecute a request against a specified URL. Defaults to the home URL.\n\n\t[--fields=\u003cfields\u003e]\n\t\tLimit the output to specific fields. Default is all fields.\n\n\t[--format=\u003cformat\u003e]\n\t\tRender output in a particular format.\n\t\t---\n\t\tdefault: table\n\t\toptions:\n\t\t  - table\n\t\t  - json\n\t\t  - yaml\n\t\t  - csv\n\t\t---\n\n\t[--order=\u003corder\u003e]\n\t\tAscending or Descending order.\n\t\t---\n\t\tdefault: ASC\n\t\toptions:\n\t\t  - ASC\n\t\t  - DESC\n\t\t---\n\n\t[--orderby=\u003cfields\u003e]\n\t\tSet orderby which field.\n\n**EXAMPLES**\n\n    # See an overview for each stage of the load process.\n    $ wp profile stage --fields=stage,time,cache_ratio\n    +------------+---------+-------------+\n    | stage      | time    | cache_ratio |\n    +------------+---------+-------------+\n    | bootstrap  | 0.7994s | 93.21%      |\n    | main_query | 0.0123s | 94.29%      |\n    | template   | 0.792s  | 91.23%      |\n    +------------+---------+-------------+\n    | total (3)  | 1.6037s | 92.91%      |\n    +------------+---------+-------------+\n\n    # Dive into hook performance for a given stage.\n    $ wp profile stage bootstrap --fields=hook,time,cache_ratio --spotlight\n    +--------------------------+---------+-------------+\n    | hook                     | time    | cache_ratio |\n    +--------------------------+---------+-------------+\n    | muplugins_loaded:before  | 0.2335s | 40%         |\n    | muplugins_loaded         | 0.0007s | 50%         |\n    | plugins_loaded:before    | 0.2792s | 77.63%      |\n    | plugins_loaded           | 0.1502s | 100%        |\n    | after_setup_theme:before | 0.068s  | 100%        |\n    | init                     | 0.2643s | 96.88%      |\n    | wp_loaded:after          | 0.0377s |             |\n    +--------------------------+---------+-------------+\n    | total (7)                | 1.0335s | 77.42%      |\n    +--------------------------+---------+-------------+\n\n\n\n### wp profile hook\n\nProfile key metrics for WordPress hooks (actions and filters).\n\n~~~\nwp profile hook [\u003chook\u003e] [--all] [--spotlight] [--url=\u003curl\u003e] [--fields=\u003cfields\u003e] [--format=\u003cformat\u003e] [--order=\u003corder\u003e] [--orderby=\u003cfields\u003e]\n~~~\n\nIn order to profile callbacks on a specific hook, the action or filter\nwill need to execute during the course of the request.\n\n**OPTIONS**\n\n\t[\u003chook\u003e]\n\t\tDrill into key metrics of callbacks on a specific WordPress hook.\n\n\t[--all]\n\t\tProfile callbacks for all WordPress hooks.\n\n\t[--spotlight]\n\t\tFilter out logs with zero-ish values from the set.\n\n\t[--url=\u003curl\u003e]\n\t\tExecute a request against a specified URL. Defaults to the home URL.\n\n\t[--fields=\u003cfields\u003e]\n\t\tDisplay one or more fields.\n\n\t[--format=\u003cformat\u003e]\n\t\tRender output in a particular format.\n\t\t---\n\t\tdefault: table\n\t\toptions:\n\t\t  - table\n\t\t  - json\n\t\t  - yaml\n\t\t  - csv\n\t\t---\n\n\t[--order=\u003corder\u003e]\n\t\tAscending or Descending order.\n\t\t---\n\t\tdefault: ASC\n\t\toptions:\n\t\t  - ASC\n\t\t  - DESC\n\t\t---\n\n\t[--orderby=\u003cfields\u003e]\n\t\tSet orderby which field.\n\n**EXAMPLES**\n\n    # Profile a hook.\n    $ wp profile hook template_redirect --fields=callback,cache_hits,cache_misses\n    +--------------------------------+------------+--------------+\n    | callback                       | cache_hits | cache_misses |\n    +--------------------------------+------------+--------------+\n    | _wp_admin_bar_init()           | 0          | 0            |\n    | wp_old_slug_redirect()         | 0          | 0            |\n    | redirect_canonical()           | 5          | 0            |\n    | WP_Sitemaps-\u003erender_sitemaps() | 0          | 0            |\n    | rest_output_link_header()      | 3          | 0            |\n    | wp_shortlink_header()          | 0          | 0            |\n    | wp_redirect_admin_locations()  | 0          | 0            |\n    +--------------------------------+------------+--------------+\n    | total (7)                      | 8          | 0            |\n    +--------------------------------+------------+--------------+\n\n\n\n### wp profile eval\n\nProfile arbitrary code execution.\n\n~~~\nwp profile eval \u003cphp-code\u003e [--hook[=\u003chook\u003e]] [--fields=\u003cfields\u003e] [--format=\u003cformat\u003e] [--order=\u003corder\u003e] [--orderby=\u003cfields\u003e]\n~~~\n\nCode execution happens after WordPress has loaded entirely, which means\nyou can use any utilities defined in WordPress, active plugins, or the\ncurrent theme.\n\n**OPTIONS**\n\n\t\u003cphp-code\u003e\n\t\tThe code to execute, as a string.\n\n\t[--hook[=\u003chook\u003e]]\n\t\tFocus on key metrics for all hooks, or callbacks on a specific hook.\n\n\t[--fields=\u003cfields\u003e]\n\t\tDisplay one or more fields.\n\n\t[--format=\u003cformat\u003e]\n\t\tRender output in a particular format.\n\t\t---\n\t\tdefault: table\n\t\toptions:\n\t\t  - table\n\t\t  - json\n\t\t  - yaml\n\t\t  - csv\n\t\t---\n\n\t[--order=\u003corder\u003e]\n\t\tAscending or Descending order.\n\t\t---\n\t\tdefault: ASC\n\t\toptions:\n\t\t  - ASC\n\t\t  - DESC\n\t\t---\n\n\t[--orderby=\u003cfields\u003e]\n\t\tSet orderby which field.\n\n**EXAMPLES**\n\n    # Profile a function that makes one HTTP request.\n    $ wp profile eval 'wp_remote_get( \"https://www.apple.com/\" );' --fields=time,cache_ratio,request_count\n    +---------+-------------+---------------+\n    | time    | cache_ratio | request_count |\n    +---------+-------------+---------------+\n    | 0.1009s | 100%        | 1             |\n    +---------+-------------+---------------+\n\n\n\n### wp profile eval-file\n\nProfile execution of an arbitrary file.\n\n~~~\nwp profile eval-file \u003cfile\u003e [--hook[=\u003chook\u003e]] [--fields=\u003cfields\u003e] [--format=\u003cformat\u003e] [--order=\u003corder\u003e] [--orderby=\u003cfields\u003e]\n~~~\n\nFile execution happens after WordPress has loaded entirely, which means\nyou can use any utilities defined in WordPress, active plugins, or the\ncurrent theme.\n\n**OPTIONS**\n\n\t\u003cfile\u003e\n\t\tThe path to the PHP file to execute and profile.\n\n\t[--hook[=\u003chook\u003e]]\n\t\tFocus on key metrics for all hooks, or callbacks on a specific hook.\n\n\t[--fields=\u003cfields\u003e]\n\t\tDisplay one or more fields.\n\n\t[--format=\u003cformat\u003e]\n\t\tRender output in a particular format.\n\t\t---\n\t\tdefault: table\n\t\toptions:\n\t\t  - table\n\t\t  - json\n\t\t  - yaml\n\t\t  - csv\n\t\t---\n\n\t[--order=\u003corder\u003e]\n\t\tAscending or Descending order.\n\t\t---\n\t\tdefault: ASC\n\t\toptions:\n\t\t  - ASC\n\t\t  - DESC\n\t\t---\n\n\t[--orderby=\u003cfields\u003e]\n\t\tSet orderby which field.\n\n**EXAMPLES**\n\n    # Profile from a file `request.php` containing `\u003c?php wp_remote_get( \"https://www.apple.com/\" );`.\n    $ wp profile eval-file request.php --fields=time,cache_ratio,request_count\n    +---------+-------------+---------------+\n    | time    | cache_ratio | request_count |\n    +---------+-------------+---------------+\n    | 0.1009s | 100%        | 1             |\n    +---------+-------------+---------------+\n\n## Installing\n\nInstalling this package requires WP-CLI v2.12 or greater. Update to the latest stable release with `wp cli update`.\n\nOnce you've done so, you can install the latest stable version of this package with:\n\n```bash\nwp package install wp-cli/profile-command:@stable\n```\n\nTo install the latest development version of this package, use the following command instead:\n\n```bash\nwp package install wp-cli/profile-command:dev-main\n```\n\n## Contributing\n\nWe appreciate you taking the initiative to contribute to this project.\n\nContributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.\n\nFor a more thorough introduction, [check out WP-CLI's guide to contributing](https://make.wordpress.org/cli/handbook/contributing/). This package follows those policy and guidelines.\n\n### Reporting a bug\n\nThink you’ve found a bug? We’d love for you to help us get it fixed.\n\nBefore you create a new issue, you should [search existing issues](https://github.com/wp-cli/profile-command/issues?q=label%3Abug%20) to see if there’s an existing resolution to it, or if it’s already been fixed in a newer version.\n\nOnce you’ve done a bit of searching and discovered there isn’t an open or fixed issue for your bug, please [create a new issue](https://github.com/wp-cli/profile-command/issues/new). Include as much detail as you can, and clear steps to reproduce if possible. For more guidance, [review our bug report documentation](https://make.wordpress.org/cli/handbook/bug-reports/).\n\n### Creating a pull request\n\nWant to contribute a new feature? Please first [open a new issue](https://github.com/wp-cli/profile-command/issues/new) to discuss whether the feature is a good fit for the project.\n\nOnce you've decided to commit the time to seeing your pull request through, [please follow our guidelines for creating a pull request](https://make.wordpress.org/cli/handbook/pull-requests/) to make sure it's a pleasant experience. See \"[Setting up](https://make.wordpress.org/cli/handbook/pull-requests/#setting-up)\" for details specific to working on this package locally.\n\n\n*This README.md is generated dynamically from the project's codebase using `wp scaffold package-readme` ([doc](https://github.com/wp-cli/scaffold-package-command#wp-scaffold-package-readme)). To suggest changes, please submit a pull request against the corresponding part of the codebase.*\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwp-cli%2Fprofile-command","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwp-cli%2Fprofile-command","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwp-cli%2Fprofile-command/lists"}