Skip to content

Instantly share code, notes, and snippets.

PHP String Comparison Benchmark Results

Performance comparison of different string matching methods in PHP.

Case-Sensitive Comparison Results

Test Setup:

  • String length: 76,000 bytes
  • Iterations: 1000 per method
  • Each test run was a separate, sequential php CLI call to minimize interference
@sirreal
sirreal / blueprint.json
Created September 15, 2025 09:11
Demo trac 63963
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"landingPage": "/?p=4",
"login": true,
"steps": [
{
"step": "installTheme",
"themeData": {
"resource": "wordpress.org/themes",
"slug": "twentyfifteen"
@sirreal
sirreal / script-data-escape.dot
Last active August 14, 2025 07:54
HTML Script data tokenization diagrams
// Credit: Dennis Snell (@dmsnell)
digraph G {
rankdir=TB;
nodesep=0.5;
ranksep=0.8;
fontname="sans-serif";
// Entry point
entry [shape=plaintext label="Open script"];
entry -> script_data;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sirreal
sirreal / main.ts
Last active April 14, 2025 10:31
CodeMirror CSS theme export
import { oneDarkHighlightStyle } from '@codemirror/theme-one-dark';
import { classHighlighter } from '@lezer/highlight';
import { defaultHighlightStyle } from '@codemirror/language';
const ss = new CSSStyleSheet();
for (const spec of oneDarkHighlightStyle.specs) {
const { tag: _tags, class: _, ...rules } = spec;
const tags: Extract<typeof _tags, readonly any[]> = Array.isArray(_tags)
? _tags
@sirreal
sirreal / blueprint.json
Created May 6, 2024 10:45
WP playground blueprint - Script Modules data sharing
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"landingPage": "/",
"phpExtensionBundles": [
"kitchen-sink"
],
"steps": [
{
"step": "mkdir",
"path": "/wordpress-new"
@sirreal
sirreal / Dockerfile.php7
Created February 6, 2024 11:53
Demo php clase name collision problems
FROM php:7.0-alpine
COPY . .
ENTRYPOINT ["php", "a.php"]
@sirreal
sirreal / index.html
Last active January 25, 2024 14:49
Test PR 58258
<body>
<div
data-wp-interactive='{"namespace":"jon/the-block"}'
data-wp-context='{"val":0}'
>
<input
readonly
type="number"
class="jon-val"
data-wp-bind--value="context.val"
@sirreal
sirreal / block.json
Last active January 24, 2024 15:03
Demo of viewScriptModule
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"title": "Jon's cool counter",
"name": "jon/the-block",
"editorScript": "file:./index.js",
"viewScriptModule": "file:./view.js",
"render": "file:./render.php",
"category": "text"
}
@sirreal
sirreal / block.json
Last active January 8, 2024 15:44
A simple WordPress block plugin with block.json viewModule
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"title": "Jon's cool counter",
"name": "jon/the-block",
"editorScript": "file:./index.js",
"viewModule": "file:./view.js",
"render": "file:./render.php",
"category": "text"
}