Skip to content

Benchmark setup HTML API#30

Draft
sirreal wants to merge 36 commits intotrunkfrom
bench-html-api
Draft

Benchmark setup HTML API#30
sirreal wants to merge 36 commits intotrunkfrom
bench-html-api

Conversation

@sirreal
Copy link
Copy Markdown
Owner

@sirreal sirreal commented Mar 11, 2026

Trac ticket:

Use of AI Tools


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request establishes a foundational benchmarking setup for the HTML API using PHPBench. It integrates the benchmarking tool, configures the WordPress environment for benchmark execution, and provides initial performance tests for the WP_HTML_Tag_Processor and WP_HTML_Processor classes. This will allow for systematic performance measurement and optimization of HTML processing within WordPress.

Highlights

  • Benchmarking Tool Integration: Integrated phpbench/phpbench as a development dependency to enable performance benchmarking within the project.
  • WordPress Bootstrap for Benchmarks: Introduced phpbench-bootstrap.php to properly load the WordPress environment, including global variables and constants, specifically for benchmark execution.
  • PHPBench Configuration: Added phpbench.json to configure PHPBench, specifying the bootstrap file and the directory where benchmark files are located.
  • Code Standard Exclusions: Updated phpcs.xml.dist to exclude benchmark files from specific PHP Code Sniffer rules related to naming conventions and file names.
  • Initial HTML API Benchmarks: Created WpHtmlTagProcessorBench.php with initial benchmarks for WP_HTML_Tag_Processor and WP_HTML_Processor to measure various aspects of HTML parsing performance.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • composer.json
    • Added phpbench/phpbench as a development dependency.
  • phpbench-bootstrap.php
    • Added a new file to bootstrap the WordPress environment for PHPBench benchmarks, including globalizing WordPress variables and defining constants.
  • phpbench.json
    • Added a new configuration file for PHPBench, specifying the bootstrap script and the directory for benchmark files.
  • phpcs.xml.dist
    • Excluded benchmark files in tests/benchmarks/benchmarks/* from PEAR.NamingConventions.ValidClassName.Invalid rule.
    • Excluded benchmark files in tests/benchmarks/benchmarks/* from WordPress.Files.FileName rule.
  • tests/benchmarks/benchmarks/html-api/WpHtmlTagProcessorBench.php
    • Added a new benchmark class for WP_HTML_Tag_Processor and WP_HTML_Processor, including tests for JavaScript custom escape and various HTML parsing scenarios.
Activity
  • This is a new pull request opened for code review, intended to set up benchmarking for the HTML API. Further discussion is directed to the associated Trac ticket.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively sets up the infrastructure for benchmarking the HTML API using PHPBench. The changes to composer.json and phpcs.xml.dist are appropriate, and the initial benchmark file for WpHtmlTagProcessor is well-structured. I have a few minor suggestions in phpbench-bootstrap.php to improve error reporting and remove a redundant line of code. I also have a small style suggestion in the benchmark file itself to align with coding standards.

Comment thread phpbench-bootstrap.php
Comment on lines +21 to +23
if ( ! is_readable( $config_file_path ) ) {
exit( 1 );
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better debugging, it's helpful to output an error message to stderr when the script exits due to a fatal condition. This will make it easier to diagnose setup issues when running the benchmarks.

if ( ! is_readable( $config_file_path ) ) {
	fwri te( STDERR, "Error: Could not read the WordPress test configuration file from {$config_file_path}. Aborting.\n" );
	exit( 1 );
}

Comment thread phpbench-bootstrap.php
Comment on lines +27 to +29
if ( ! is_dir( ABSPATH ) ) {
exit( 1 );
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the check above, adding an error message here would improve debuggability if ABSPATH is not correctly defined or doesn't point to a directory.

if ( ! is_dir( ABSPATH ) ) {
	fwrite( STDERR, 'Error: The ABSPATH ' . ABSPATH . " is not a directory. Aborting.\n" );
	exit( 1 );
}

Comment thread phpbench-bootstrap.php
define( 'WP_MAX_MEMORY_LIMIT', -1 );

$PHP_SELF = '/index.php';
$GLOBALS['PHP_SELF'] = '/index.php';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This line is redundant. $PHP_SELF is a global variable, so assigning to it on line 60 is sufficient to set the global value. This line can be removed.

#[Bench\AfterMethods( 'clean_up_processor' )]
#[Bench\ParamProviders( 'provide_script_tag_contents' )]
public function bench_javascript_custom_escape( array $params ): void {
[ $source_text] = $params;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To adhere to common PHP coding standards (like PSR-12) and improve consistency, array destructuring should not have a space before the closing bracket. The standard form is [$var] = $array;.

		[$source_text] = $params;

westonruter and others added 26 commits March 31, 2026 17:01
…it HTML file.

The markup had surely been copied from the PHP source file, as opposed to being copied from the rendered HTML, as it should have been.

Developed in WordPress#11403

Follow-up to r41773.

Props westonruter, jonsurrell, desrosj, SergeyBiryukov.
See #64225, #40104.


git-svn-id: https://develop.svn.wordpress.org/trunk@62184 602fd350-edb4-49c9-b593-d223f7449a82
… "Notes".

"Notes" translation string is used in both the Notes features and in the Link Manager, and they can have different meaning in some Locales, like in German for example. This changeset helps disambuguating these different contexts.

Props westonruter, dmsnell, johnbillion.
Fixes #64980.



git-svn-id: https://develop.svn.wordpress.org/trunk@62185 602fd350-edb4-49c9-b593-d223f7449a82
… "Bulk Edit".

The "Bulk Edit" translation string is used for both verbs and nouns, and may have different translations in some Locales. This changeset helps disambuguating these different contexts.

Follow-up to [61255].

Props audrasjb, shailu25.
Fixes #64994.



git-svn-id: https://develop.svn.wordpress.org/trunk@62186 602fd350-edb4-49c9-b593-d223f7449a82
In [62145], an `::after` CSS rule was added that caused an overflow, resulting in an unintended scrollbar always appearing on Windows OS for example. This changeset removes the related CSS rule which is unnecessary to fix the initial issue. 

Follow-up to [62145].

Props wildworks, SergeyBiryukov, sabernhardt, audrasjb, huzaifaalmesbah, mehrazmorshed, mukesh27.
Fixes #64744.



git-svn-id: https://develop.svn.wordpress.org/trunk@62187 602fd350-edb4-49c9-b593-d223f7449a82
Follow-up to [37849].

Props timse201, anupkankale.
Fixes #65005.

git-svn-id: https://develop.svn.wordpress.org/trunk@62188 602fd350-edb4-49c9-b593-d223f7449a82
Relocates the `copy-vendor-scripts` to run during the the `build:js` portion of the build script. This ensures the JavaScript files are in place before the `uglify:all` task is run.

Follow up to r61438

Props desrosj.
Fixes #65006. See #64393.


git-svn-id: https://develop.svn.wordpress.org/trunk@62189 602fd350-edb4-49c9-b593-d223f7449a82
Update min-height from 30px to 32px for the color picker button and related elements to match new design system.

Props audrasjb, hmbashar, huzaifaalmesbah, joedolson, juanmaguitar, mukesh27, noruzzaman, ozgursar, rahultank, rcorrales, sajib1223, tusharaddweb, vgnavada, wildworks.

Fixes #64761.

git-svn-id: https://develop.svn.wordpress.org/trunk@62191 602fd350-edb4-49c9-b593-d223f7449a82
…istration.

Use the plugin's main file path relative to the plugins directory
(e.g. `akismet/akismet.php` or `hello.php`) instead of the WordPress.org slug
to identify a connector's associated plugin.
This lets `_wp_connectors_get_connector_script_module_data()` check plugin
status with `file_exists()` and `is_plugin_active()` directly, removing the
`get_plugins()` slug-to-file mapping that was previously needed.

Props jorgefilipecosta, mukesh27, gziolo.
Fixes #65002.

git-svn-id: https://develop.svn.wordpress.org/trunk@62192 602fd350-edb4-49c9-b593-d223f7449a82
Akismet comes with core but the connectors screen was not showing akismet even if akismet was on the file system. This commit fixes the issue.

Props jorgefilipecosta, bluefuton, gziolo.
Fixes #65012.

git-svn-id: https://develop.svn.wordpress.org/trunk@62193 602fd350-edb4-49c9-b593-d223f7449a82
…e screen.

Follow-up to [61645].

Props mukesh27, wildworks, audrasjb, shailu25, anupkankale, kapilpaul, SergeyBiryukov.
Fixes #65009.

git-svn-id: https://develop.svn.wordpress.org/trunk@62196 602fd350-edb4-49c9-b593-d223f7449a82
Adds additional validation and permission checks the the Real Time Collaboration endpoint to ensure only input in the expected format is supported.

Props czarate, westonruter, joefusco.
Fixes #64890.




git-svn-id: https://develop.svn.wordpress.org/trunk@62198 602fd350-edb4-49c9-b593-d223f7449a82
Update the colors used for the file upload overlay mask to use the new admin theme colors.

Props opurockey, huzaifaalmesbah, wildworks, audrasjb, manhar, joedolson.
Fixes #65001.

git-svn-id: https://develop.svn.wordpress.org/trunk@62199 602fd350-edb4-49c9-b593-d223f7449a82
The design changes to admin notices links in the admin refresh were applied broadly to `.notice, .error, and .updated` classes, but these classes are sometimes used outside the context of an admin notice.

Change selectors from `.notice a, .error a, .updated a` to `div.notice a, div.error a, div.updated a`.

Props opurockey, audrasjb, vgnavada, gaisma22, shailu25, rbcorrales, joedolson.
Fixes #64976.

git-svn-id: https://develop.svn.wordpress.org/trunk@62200 602fd350-edb4-49c9-b593-d223f7449a82
Follow-up to [56805], [59101].

Props Soean, mukesh27.
See #64898.

git-svn-id: https://develop.svn.wordpress.org/trunk@62201 602fd350-edb4-49c9-b593-d223f7449a82
…sistency.

This ensures that data providers or helper functions used by a single test are located next to the test, for consistency with the rest of the test suite.

Follow-up to [37905], [37943], [45809], [47239], [47260], [47351], [48947], [49252], [49257], [51960], [53110], [56096], [59032].

See #64225.

git-svn-id: https://develop.svn.wordpress.org/trunk@62205 602fd350-edb4-49c9-b593-d223f7449a82
This changeset fixes a CSS glitch on dashboard widgets bottom border when they are collapsed.

Follow-up to [61646].

Props pratik-jain, audrasjb, ankitkumarshah.
Fixes #65017.
See #64549.



git-svn-id: https://develop.svn.wordpress.org/trunk@62206 602fd350-edb4-49c9-b593-d223f7449a82
Includes:
* Adding missing `@covers` tags.
* Correcting test class names as per the naming conventions.
* Moving `wp_check_invalid_utf8()` tests to their own file, separate from `wp_scrub_utf8()`.

Follow-up to [60630], [60793], [61000].

See #64225.

git-svn-id: https://develop.svn.wordpress.org/trunk@62207 602fd350-edb4-49c9-b593-d223f7449a82
This aims to make the tests more discoverable and easier to expand.

Follow-up to [36631], [39169], [43359], [44514].

See #64225.

git-svn-id: https://develop.svn.wordpress.org/trunk@62208 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants