Skip to content

docs: automate API.md generation from Judy.stub.php#64

Merged
orieg merged 3 commits intomainfrom
docs/automate-api-docs-generation
Mar 3, 2026
Merged

docs: automate API.md generation from Judy.stub.php#64
orieg merged 3 commits intomainfrom
docs/automate-api-docs-generation

Conversation

@orieg
Copy link
Owner

@orieg orieg commented Mar 3, 2026

Summary

  • Enriched Judy.stub.php with PHPDoc descriptions on all 46 methods and 2 global functions (benefits IDEs and serves as source of truth for API docs)
  • Created scripts/api-metadata.php — supplemental metadata file with type groupings, examples, compatibility matrix, and behavioral notes that don't fit in PHPDoc
  • Created scripts/generate-api-docs.php — PHP generator script that produces API.md from both sources, with drift detection between stub and metadata
  • Added CI step (--check mode, PHP 8.4 only) to verify API.md stays in sync with source files

Design

Dual-source approach: Stub provides signatures + descriptions; PHP array metadata provides type groupings, examples, supported-type annotations, compatibility matrix, and behavioral notes.

Drift detection: Generator cross-checks stub methods vs metadata sections and constants vs type_groups. Fails with clear errors if out of sync.

Stub safety: Only prose text in PHPDoc (no @param/@return with descriptions) to avoid breaking gen_stub.php arginfo generation.

Test plan

  • php scripts/generate-api-docs.php --check exits 0 (API.md matches generated output)
  • CI passes on all PHP versions (8.1-8.5)
  • Judy_arginfo.h changes are functionally identical (only alias optimizations and hash line)
  • Introducing a deliberate stub/metadata mismatch causes the generator to fail with clear error

Enrich Judy.stub.php with PHPDoc descriptions (benefiting IDEs),
add scripts/api-metadata.php for supplemental metadata (type groups,
examples, compatibility matrix), and scripts/generate-api-docs.php
to generate API.md from both sources with drift detection.

CI step added to verify API.md stays in sync (PHP 8.4 only).
@gemini-code-assist
Copy link

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 introduces a robust, automated system for generating and maintaining the API.md documentation for the PHP Judy extension. By centralizing documentation details across PHPDoc comments in the stub file and a dedicated metadata script, it ensures consistency, accuracy, and ease of updates. The new workflow streamlines the documentation process and integrates checks to prevent documentation from becoming stale.

Highlights

  • Automated API Documentation: Implemented a new system to automatically generate API.md from Judy.stub.php and a new metadata file.
  • PHPDoc Enrichment: Enriched Judy.stub.php with comprehensive PHPDoc descriptions for all 46 methods and 2 global functions, improving IDE support and serving as the primary source for API docs.
  • Supplemental Metadata: Introduced scripts/api-metadata.php to store additional documentation details such as type groupings, examples, compatibility matrices, and behavioral notes that are not suitable for PHPDoc.
  • Documentation Generation Script: Created scripts/generate-api-docs.php, a PHP script that processes both the stub file and the metadata to produce the API.md file.
  • CI Integration with Drift Detection: Added a Continuous Integration (CI) step that uses a --check mode to verify API.md remains synchronized with its source files, failing if any drift is detected.
Changelog
  • API.md
    • Added a specific heading for the __construct() method.
    • Removed the mixed type hint from the judy_type function signature.
    • Adjusted column widths within the type compatibility matrix for better formatting.
  • Judy.stub.php
    • Added detailed PHPDoc comments to all global functions (judy_version, judy_type) and class methods within the Judy class.
    • Updated section comments for clarity, such as changing 'Set operations (BITSET)' to 'Set operations'.
  • Judy_arginfo.h
    • Updated the stub hash to reflect changes in Judy.stub.php.
    • Modified arginfo_class_Judy_keys and arginfo_class_Judy_values to alias arginfo_class_Judy___serialize.
    • Reordered the definitions for arginfo_class_Judy_averageValues and arginfo_class_Judy_sumValues.
    • Removed extraneous blank lines.
  • package.xml
    • Added scripts/api-metadata.php and scripts/generate-api-docs.php to the package manifest as documentation files.
  • scripts/api-metadata.php
    • New file: Defines supplemental metadata for API documentation, including type groupings, method-specific details, examples, and a comprehensive compatibility matrix.
  • scripts/generate-api-docs.php
    • New file: Implements a PHP script to parse Judy.stub.php and api-metadata.php to automatically generate the API.md documentation, including PHPDoc parsing, signature extraction, and drift detection.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/ci.yml
Activity
  • The pull request was created.
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

@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 introduces an automated API documentation generation process, which is a significant improvement for maintaining documentation consistency. The Judy.stub.php file has been enriched with comprehensive PHPDoc comments, and new scripts (api-metadata.php and generate-api-docs.php) are added to produce API.md. The drift detection mechanism is a valuable addition to prevent inconsistencies between the stub and metadata. The identified issues related to type hinting consistency and script robustness remain relevant and should be addressed.

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Test Results

PHP Platform Arch TS Tests Pass Fail Skip Duration
8.1 Linux x64 - 176 176 0 0 1.6s
8.2 Linux x64 - 176 176 0 0 1.9s
8.3 Linux x64 - 176 176 0 0 1.7s
8.4 Linux x64 - 176 176 0 0 2.1s
8.5 Linux x64 - 176 176 0 0 2.0s
8.1 Windows x64 nts 176 176 0 0 8.3s
8.2 Windows x64 nts 176 176 0 0 8.6s
8.3 Windows x64 nts 176 176 0 0 8.4s
8.4 Windows x64 nts 176 176 0 0 8.5s
8.5 Windows x64 nts 176 176 0 0 8.6s
Total 1760 1760 0 0

Benchmark Results

500,000 elements, 7 iterations (median), Judy 2.4.0

Run Status

Platform PHP 8.1 PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
Linux
Windows

Memory Efficiency (Linux, PHP 8.5)

Type Judy PHP array Savings
Bitset 160 B 8.0 MB 52454.9x less
Int to Int 160 B 8.0 MB 52454.9x less
Int to Mixed 7.6 MB 8.0 MB ~1.0x
Int to Packed 13.3 MB 8.0 MB 0.6x
String to Int 64.2 KB 20.0 MB 319.2x less
String to Mixed 7.7 MB 20.0 MB 2.6x less
String to Int (Hash) 64.2 KB 20.0 MB 319.2x less
String to Mixed (Hash) 7.7 MB 20.0 MB 2.6x less
String to Int (Adaptive) 64.2 KB 20.0 MB 319.2x less
String to Mixed (Adaptive) 7.7 MB 20.0 MB 2.6x less

API Speedups (Linux, PHP 8.5)

Speedup = PHP time / Judy time. Bold = Judy faster.

Operation Judy PHP Speedup
putAll() 26.1 ms 35.9 ms 1.4x
fromArray() 25.9 ms 35.9 ms 1.4x
toArray() 24.5 ms 38.6 ms 1.6x
getAll() 1.5 ms 2.3 ms 1.6x
keys() 11.9 ms 25.0 ms 2.1x
values() 11.7 ms 24.7 ms 2.1x
sumValues() 7.9 ms 19.3 ms 2.4x
populationCount() 0.00 ms 20.0 ms 199534x
deleteRange() 52.7 ms 69.8 ms 1.3x
equals() 13.7 ms 53.6 ms 3.9x
union() Bitset 38.3 ms 5.0 ms 0.1x
intersect() Bitset 17.1 ms 5.8 ms 0.3x
diff() Bitset 17.6 ms 3.4 ms 0.2x
xor() Bitset 35.6 ms 12.0 ms 0.3x
mergeWith() Int→Int 68.0 ms 75.5 ms 1.1x
mergeWith() Str→Int 294.7 ms 285.1 ms ~1.0x
forEach() Int→Int 27.7 ms 22.9 ms 0.8x
filter() Int→Int 55.4 ms 43.6 ms 0.8x
map() Int→Int 58.3 ms 55.1 ms 0.9x
forEach() Str→Int 75.0 ms 65.5 ms 0.9x
filter() Str→Int 148.3 ms 120.6 ms 0.8x
map() Str→Int 174.3 ms 170.8 ms ~1.0x

Core Types (Linux, PHP 8.5)

Speedup = PHP time / Judy time. Bold = Judy faster.

Type Op Judy PHP array Speedup
Bitset Write 20.6 ms 7.4 ms 0.4x
Bitset Read 12.6 ms 3.9 ms 0.3x
Bitset Iter 18.4 ms 3.1 ms 0.2x
Bitset Free 0.01 ms 0.35 ms 63.0x
Int to Int Write 29.8 ms 7.4 ms 0.2x
Int to Int Read 14.7 ms 3.9 ms 0.3x
Int to Int Iter 20.0 ms 3.1 ms 0.2x
Int to Int Free 0.21 ms 0.35 ms 1.7x
Int to Mixed Write 39.5 ms 10.9 ms 0.3x
Int to Mixed Read 17.6 ms 5.6 ms 0.3x
Int to Mixed Iter 21.3 ms 3.6 ms 0.2x
Int to Mixed Free 15.0 ms 4.5 ms 0.3x
String to Int Write 103.0 ms 16.8 ms 0.2x
String to Int Read 41.6 ms 7.3 ms 0.2x
String to Int Iter 63.7 ms 4.6 ms 0.1x
String to Int Free 22.9 ms 1.4 ms 0.1x
String to Int (Adaptive) Write 160.6 ms 17.0 ms 0.1x
String to Int (Adaptive) Read 26.9 ms 7.3 ms 0.3x
String to Int (Adaptive) Iter 78.6 ms 4.6 ms 0.1x
String to Int (Adaptive) Free 45.8 ms 1.5 ms 0.0x
All types detail

Core Types (Linux, PHP 8.5) — All

Speedup = PHP time / Judy time. Bold = Judy faster.

Type Op Judy PHP array Speedup
Bitset Write 20.6 ms 7.4 ms 0.4x
Bitset Read 12.6 ms 3.9 ms 0.3x
Bitset Iter 18.4 ms 3.1 ms 0.2x
Bitset Free 0.01 ms 0.35 ms 63.0x
Int to Int Write 29.8 ms 7.4 ms 0.2x
Int to Int Read 14.7 ms 3.9 ms 0.3x
Int to Int Iter 20.0 ms 3.1 ms 0.2x
Int to Int Free 0.21 ms 0.35 ms 1.7x
Int to Mixed Write 39.5 ms 10.9 ms 0.3x
Int to Mixed Read 17.6 ms 5.6 ms 0.3x
Int to Mixed Iter 21.3 ms 3.6 ms 0.2x
Int to Mixed Free 15.0 ms 4.5 ms 0.3x
Int to Packed Write 52.0 ms 10.2 ms 0.2x
Int to Packed Read 35.1 ms 5.7 ms 0.2x
Int to Packed Iter 39.2 ms 3.6 ms 0.1x
Int to Packed Free 10.9 ms 4.5 ms 0.4x
String to Int Write 103.0 ms 16.8 ms 0.2x
String to Int Read 41.6 ms 7.3 ms 0.2x
String to Int Iter 63.7 ms 4.6 ms 0.1x
String to Int Free 22.9 ms 1.4 ms 0.1x
String to Mixed Write 125.5 ms 20.7 ms 0.2x
String to Mixed Read 44.5 ms 9.7 ms 0.2x
String to Mixed Iter 70.4 ms 6.1 ms 0.1x
String to Mixed Free 76.5 ms 8.0 ms 0.1x
String to Int (Hash) Write 175.0 ms 17.0 ms 0.1x
String to Int (Hash) Read 27.7 ms 7.3 ms 0.3x
String to Int (Hash) Iter 79.2 ms 4.6 ms 0.1x
String to Int (Hash) Free 44.8 ms 1.4 ms 0.0x
String to Mixed (Hash) Write 261.0 ms 20.5 ms 0.1x
String to Mixed (Hash) Read 31.0 ms 9.7 ms 0.3x
String to Mixed (Hash) Iter 95.6 ms 6.4 ms 0.1x
String to Mixed (Hash) Free 139.2 ms 7.6 ms 0.1x
String to Int (Adaptive) Write 160.6 ms 17.0 ms 0.1x
String to Int (Adaptive) Read 26.9 ms 7.3 ms 0.3x
String to Int (Adaptive) Iter 78.6 ms 4.6 ms 0.1x
String to Int (Adaptive) Free 45.8 ms 1.5 ms 0.0x
String to Mixed (Adaptive) Write 259.7 ms 20.9 ms 0.1x
String to Mixed (Adaptive) Read 29.0 ms 9.7 ms 0.3x
String to Mixed (Adaptive) Iter 92.8 ms 6.3 ms 0.1x
String to Mixed (Adaptive) Free 140.4 ms 8.7 ms 0.1x
Cross-version detail (Linux)

Core Types — Linux

Each cell: Judy ms (speedup vs PHP array).

Type Op PHP 8.1 PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
Bitset Write 19.8 ms (0.4x) 19.8 ms (0.3x) 20.0 ms (0.4x) 21.8 ms (0.3x) 20.6 ms (0.4x)
Bitset Read 11.9 ms (0.4x) 11.8 ms (0.3x) 11.4 ms (0.3x) 12.8 ms (0.3x) 12.6 ms (0.3x)
Int to Int Write 29.9 ms (0.3x) 29.1 ms (0.2x) 29.0 ms (0.3x) 31.4 ms (0.2x) 29.8 ms (0.2x)
Int to Int Read 13.6 ms (0.3x) 13.5 ms (0.3x) 13.4 ms (0.3x) 14.8 ms (0.3x) 14.7 ms (0.3x)
Int to Mixed Write 38.9 ms (0.3x) 39.3 ms (0.3x) 42.2 ms (0.2x) 40.5 ms (0.3x) 39.5 ms (0.3x)
Int to Mixed Read 16.8 ms (0.4x) 17.0 ms (0.3x) 16.3 ms (0.3x) 17.3 ms (0.4x) 17.6 ms (0.3x)
Int to Packed Write 54.9 ms (0.2x) 52.3 ms (0.2x) 51.7 ms (0.2x) 51.0 ms (0.2x) 52.0 ms (0.2x)
Int to Packed Read 33.9 ms (0.2x) 34.5 ms (0.2x) 33.0 ms (0.2x) 33.1 ms (0.2x) 35.1 ms (0.2x)
String to Int Write 102.3 ms (0.2x) 103.8 ms (0.2x) 102.9 ms (0.2x) 108.6 ms (0.1x) 103.0 ms (0.2x)
String to Int Read 41.4 ms (0.2x) 41.2 ms (0.2x) 40.7 ms (0.2x) 45.6 ms (0.2x) 41.6 ms (0.2x)
String to Mixed Write 126.4 ms (0.1x) 126.9 ms (0.2x) 125.9 ms (0.2x) 136.2 ms (0.1x) 125.5 ms (0.2x)
String to Mixed Read 44.7 ms (0.2x) 44.6 ms (0.2x) 44.7 ms (0.2x) 48.7 ms (0.2x) 44.5 ms (0.2x)
String to Int (Hash) Write 184.4 ms (0.1x) 180.1 ms (0.1x) 172.6 ms (0.1x) 182.7 ms (0.1x) 175.0 ms (0.1x)
String to Int (Hash) Read 27.6 ms (0.3x) 27.5 ms (0.3x) 27.2 ms (0.3x) 30.1 ms (0.3x) 27.7 ms (0.3x)
String to Mixed (Hash) Write 268.2 ms (0.1x) 259.9 ms (0.1x) 250.9 ms (0.1x) 276.8 ms (0.1x) 261.0 ms (0.1x)
String to Mixed (Hash) Read 29.8 ms (0.3x) 30.4 ms (0.3x) 29.3 ms (0.3x) 33.1 ms (0.3x) 31.0 ms (0.3x)
String to Int (Adaptive) Write 166.5 ms (0.1x) 162.7 ms (0.1x) 154.9 ms (0.1x) 163.8 ms (0.1x) 160.6 ms (0.1x)
String to Int (Adaptive) Read 26.9 ms (0.3x) 27.1 ms (0.3x) 26.3 ms (0.3x) 29.9 ms (0.3x) 26.9 ms (0.3x)
String to Mixed (Adaptive) Write 270.9 ms (0.1x) 260.2 ms (0.1x) 253.4 ms (0.1x) 277.7 ms (0.1x) 259.7 ms (0.1x)
String to Mixed (Adaptive) Read 29.1 ms (0.3x) 29.2 ms (0.3x) 28.7 ms (0.3x) 32.2 ms (0.3x) 29.0 ms (0.3x)

API — Linux

Operation PHP 8.1 PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
putAll() 25.8 ms (1.3x) 26.1 ms (1.3x) 26.0 ms (1.3x) 28.2 ms (1.3x) 26.1 ms (1.4x)
fromArray() 25.7 ms (1.3x) 25.9 ms (1.4x) 25.9 ms (1.3x) 28.2 ms (1.3x) 25.9 ms (1.4x)
toArray() 25.6 ms (1.5x) 25.1 ms (1.5x) 24.8 ms (1.5x) 24.8 ms (1.5x) 24.5 ms (1.6x)
getAll() 1.4 ms (1.7x) 1.5 ms (1.6x) 1.5 ms (1.6x) 1.5 ms (1.6x) 1.5 ms (1.6x)
keys() 13.3 ms (2.0x) 11.7 ms (2.2x) 11.6 ms (2.2x) 12.5 ms (2.0x) 11.9 ms (2.1x)
values() 14.8 ms (1.8x) 12.1 ms (2.1x) 11.4 ms (2.2x) 12.5 ms (2.1x) 11.7 ms (2.1x)
sumValues() 8.1 ms (2.5x) 7.3 ms (2.7x) 7.4 ms (2.9x) 8.0 ms (2.6x) 7.9 ms (2.4x)
populationCount() 0.00 ms (213990x) 0.00 ms (206859x) 0.00 ms (213078x) 0.00 ms (233836x) 0.00 ms (199534x)
deleteRange() 51.9 ms (1.3x) 51.5 ms (1.3x) 51.3 ms (1.3x) 55.1 ms (1.2x) 52.7 ms (1.3x)
equals() 14.7 ms (3.4x) 14.3 ms (3.5x) 13.7 ms (3.8x) 15.7 ms (3.2x) 13.7 ms (3.9x)
union() Bitset 37.6 ms (0.2x) 37.4 ms (0.1x) 37.4 ms (0.1x) 39.7 ms (0.1x) 38.3 ms (0.1x)
intersect() Bitset 16.9 ms (0.3x) 16.8 ms (0.3x) 16.7 ms (0.3x) 18.3 ms (0.3x) 17.1 ms (0.3x)
diff() Bitset 16.7 ms (0.2x) 16.7 ms (0.2x) 16.7 ms (0.2x) 18.1 ms (0.2x) 17.6 ms (0.2x)
xor() Bitset 34.0 ms (0.5x) 33.9 ms (0.4x) 33.8 ms (0.4x) 36.9 ms (0.3x) 35.6 ms (0.3x)
mergeWith() Int→Int 68.7 ms (1.1x) 68.3 ms (1.1x) 67.4 ms (1.1x) 73.5 ms (~1.0x) 68.0 ms (1.1x)
mergeWith() Str→Int 291.2 ms (~1.0x) 286.2 ms (~1.0x) 284.4 ms (~1.0x) 295.2 ms (~1.0x) 294.7 ms (~1.0x)
forEach() Int→Int 27.3 ms (0.8x) 27.8 ms (0.9x) 28.5 ms (0.8x) 27.0 ms (0.9x) 27.7 ms (0.8x)
filter() Int→Int 53.9 ms (0.8x) 53.1 ms (0.8x) 53.1 ms (0.8x) 48.8 ms (0.8x) 55.4 ms (0.8x)
map() Int→Int 59.7 ms (0.9x) 56.7 ms (~1.0x) 55.9 ms (~1.0x) 52.3 ms (~1.0x) 58.3 ms (0.9x)
forEach() Str→Int 71.1 ms (0.9x) 73.0 ms (0.9x) 71.1 ms (0.9x) 81.7 ms (0.8x) 75.0 ms (0.9x)
filter() Str→Int 148.4 ms (0.8x) 147.4 ms (0.8x) 146.7 ms (0.8x) 148.6 ms (0.8x) 148.3 ms (0.8x)
map() Str→Int 172.1 ms (~1.0x) 173.7 ms (~1.0x) 173.7 ms (~1.0x) 173.2 ms (~1.0x) 174.3 ms (~1.0x)
Cross-version detail (Windows)

Core Types — Windows

Each cell: Judy ms (speedup vs PHP array).

Type Op PHP 8.1 PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
Bitset Write 102.2 ms (0.1x) 101.1 ms (0.1x) 97.7 ms (0.1x) 99.6 ms (0.1x) 106.4 ms (0.1x)
Bitset Read 19.0 ms (0.4x) 19.9 ms (0.4x) 20.8 ms (0.4x) 19.5 ms (0.4x) 20.1 ms (0.4x)
Int to Int Write 76.0 ms (0.2x) 78.2 ms (0.1x) 79.0 ms (0.2x) 77.5 ms (0.1x) 77.8 ms (0.2x)
Int to Int Read 25.0 ms (0.3x) 24.3 ms (0.3x) 25.1 ms (0.3x) 26.3 ms (0.3x) 25.6 ms (0.3x)
Int to Mixed Write 93.6 ms (0.2x) 94.8 ms (0.2x) 92.9 ms (0.2x) 104.0 ms (0.2x) 101.0 ms (0.2x)
Int to Mixed Read 30.0 ms (0.4x) 28.0 ms (0.4x) 28.7 ms (0.4x) 29.3 ms (0.3x) 28.2 ms (0.3x)
Int to Packed Write 113.6 ms (0.2x) 116.7 ms (0.1x) 111.9 ms (0.1x) 123.1 ms (0.1x) 119.2 ms (0.1x)
Int to Packed Read 56.4 ms (0.2x) 56.8 ms (0.2x) 56.6 ms (0.2x) 58.5 ms (0.2x) 58.8 ms (0.2x)
String to Int Write 234.5 ms (0.1x) 233.6 ms (0.1x) 235.9 ms (0.1x) 242.0 ms (0.1x) 234.5 ms (0.1x)
String to Int Read 79.2 ms (0.1x) 81.9 ms (0.1x) 81.2 ms (0.2x) 81.4 ms (0.2x) 81.4 ms (0.1x)
String to Mixed Write 274.2 ms (0.1x) 281.3 ms (0.1x) 280.5 ms (0.1x) 288.5 ms (0.1x) 281.1 ms (0.1x)
String to Mixed Read 81.7 ms (0.2x) 83.5 ms (0.2x) 83.7 ms (0.2x) 82.8 ms (0.2x) 82.5 ms (0.2x)
String to Int (Hash) Write 414.7 ms (0.1x) 416.5 ms (0.1x) 412.7 ms (0.1x) 416.1 ms (0.1x) 414.1 ms (0.1x)
String to Int (Hash) Read 61.9 ms (0.2x) 61.9 ms (0.2x) 63.4 ms (0.2x) 64.7 ms (0.2x) 63.5 ms (0.2x)
String to Mixed (Hash) Write 566.9 ms (0.0x) 564.5 ms (0.1x) 564.8 ms (0.1x) 582.0 ms (0.1x) 566.9 ms (0.1x)
String to Mixed (Hash) Read 64.9 ms (0.2x) 70.9 ms (0.2x) 66.1 ms (0.2x) 67.9 ms (0.2x) 65.4 ms (0.2x)
String to Int (Adaptive) Write 376.5 ms (0.1x) 371.2 ms (0.1x) 369.9 ms (0.1x) 419.4 ms (0.1x) 367.3 ms (0.1x)
String to Int (Adaptive) Read 62.1 ms (0.2x) 61.8 ms (0.2x) 61.1 ms (0.2x) 65.2 ms (0.2x) 60.9 ms (0.2x)
String to Mixed (Adaptive) Write 568.3 ms (0.0x) 588.3 ms (0.1x) 574.9 ms (0.1x) 612.6 ms (0.1x) 580.3 ms (0.0x)
String to Mixed (Adaptive) Read 64.2 ms (0.2x) 63.9 ms (0.2x) 66.3 ms (0.2x) 72.4 ms (0.2x) 63.5 ms (0.2x)

API — Windows

Operation PHP 8.1 PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
putAll() 74.0 ms (1.2x) 76.7 ms (1.2x) 74.9 ms (1.4x) 75.3 ms (1.2x) 74.6 ms (1.2x)
fromArray() 73.0 ms (1.3x) 75.5 ms (1.2x) 75.4 ms (1.4x) 76.4 ms (1.2x) 74.2 ms (1.2x)
toArray() 80.8 ms (1.3x) 82.5 ms (1.3x) 80.4 ms (1.3x) 90.7 ms (1.2x) 80.4 ms (1.3x)
getAll() 2.4 ms (1.6x) 2.4 ms (1.8x) 2.4 ms (1.7x) 2.7 ms (1.6x) 2.6 ms (1.5x)
keys() 26.0 ms (1.7x) 23.2 ms (1.8x) 23.7 ms (1.8x) 23.6 ms (1.8x) 22.6 ms (1.7x)
values() 26.6 ms (1.7x) 22.8 ms (1.8x) 23.3 ms (1.8x) 23.5 ms (1.8x) 23.0 ms (1.7x)
sumValues() 17.4 ms (1.9x) 18.3 ms (1.9x) 17.8 ms (1.9x) 17.7 ms (1.9x) 17.5 ms (1.9x)
populationCount() 0.00 ms (333281x) 0.00 ms (182206x) 0.00 ms (350664x) 0.00 ms (172010x) 0.00 ms (334716x)
deleteRange() 140.5 ms (1.2x) 195.2 ms (~1.0x) 141.0 ms (1.2x) 139.9 ms (1.2x) 140.4 ms (1.2x)
equals() 31.8 ms (2.7x) 41.6 ms (2.8x) 32.0 ms (2.8x) 31.3 ms (2.8x) 31.8 ms (2.7x)
union() Bitset 182.6 ms (0.1x) 185.3 ms (0.1x) 172.5 ms (0.1x) 205.5 ms (0.0x) 184.6 ms (0.0x)
intersect() Bitset 70.8 ms (0.1x) 76.8 ms (0.1x) 67.1 ms (0.1x) 70.7 ms (0.1x) 72.8 ms (0.1x)
diff() Bitset 64.3 ms (0.1x) 70.0 ms (0.1x) 64.7 ms (0.1x) 66.9 ms (0.1x) 70.7 ms (0.1x)
xor() Bitset 136.6 ms (0.2x) 152.4 ms (0.2x) 132.4 ms (0.1x) 139.1 ms (0.1x) 144.0 ms (0.1x)
mergeWith() Int→Int 170.0 ms (~1.0x) 166.8 ms (~1.0x) 169.1 ms (1.1x) 167.7 ms (1.1x) 168.0 ms (~1.0x)
mergeWith() Str→Int 619.3 ms (~1.0x) 628.5 ms (~1.0x) 620.5 ms (~1.0x) 629.3 ms (~1.0x) 624.6 ms (~1.0x)
forEach() Int→Int 38.5 ms (0.9x) 39.1 ms (0.9x) 42.6 ms (0.9x) 40.7 ms (0.9x) 41.1 ms (0.9x)
filter() Int→Int 92.3 ms (0.9x) 90.5 ms (0.9x) 90.4 ms (0.9x) 91.7 ms (0.9x) 93.8 ms (0.8x)
map() Int→Int 108.9 ms (~1.0x) 113.4 ms (~1.0x) 108.3 ms (1.1x) 115.1 ms (1.2x) 112.9 ms (~1.0x)
forEach() Str→Int 126.0 ms (0.9x) 130.7 ms (0.9x) 129.1 ms (0.9x) 134.1 ms (0.9x) 129.2 ms (0.9x)
filter() Str→Int 282.7 ms (0.8x) 281.8 ms (0.8x) 283.2 ms (0.9x) 285.0 ms (0.9x) 283.7 ms (0.9x)
map() Str→Int 352.1 ms (~1.0x) 349.6 ms (~1.0x) 352.2 ms (~1.0x) 440.6 ms (~1.0x) 354.4 ms (~1.0x)
Windows results (PHP 8.5)

Memory Efficiency (Windows, PHP 8.5)

Type Judy PHP array Savings
Bitset 160 B 10.0 MB 65536.5x less
Int to Int 160 B 10.0 MB 65536.5x less
Int to Mixed 7.6 MB 10.0 MB 1.3x less
Int to Packed 13.3 MB 10.0 MB 0.8x
String to Int 64.2 KB 20.0 MB 319.2x less
String to Mixed 7.7 MB 20.0 MB 2.6x less
String to Int (Hash) 64.2 KB 20.0 MB 319.2x less
String to Mixed (Hash) 7.7 MB 20.0 MB 2.6x less
String to Int (Adaptive) 64.2 KB 20.0 MB 319.2x less
String to Mixed (Adaptive) 7.7 MB 20.0 MB 2.6x less

API Speedups (Windows, PHP 8.5)

Speedup = PHP time / Judy time. Bold = Judy faster.

Operation Judy PHP Speedup
putAll() 74.6 ms 88.6 ms 1.2x
fromArray() 74.2 ms 88.6 ms 1.2x
toArray() 80.4 ms 101.0 ms 1.3x
getAll() 2.6 ms 3.8 ms 1.5x
keys() 22.6 ms 39.4 ms 1.7x
values() 23.0 ms 39.7 ms 1.7x
sumValues() 17.5 ms 32.6 ms 1.9x
populationCount() 0.00 ms 33.5 ms 334716x
deleteRange() 140.4 ms 162.9 ms 1.2x
equals() 31.8 ms 86.0 ms 2.7x
union() Bitset 184.6 ms 8.9 ms 0.0x
intersect() Bitset 72.8 ms 7.6 ms 0.1x
diff() Bitset 70.7 ms 4.2 ms 0.1x
xor() Bitset 144.0 ms 17.3 ms 0.1x
mergeWith() Int→Int 168.0 ms 173.1 ms ~1.0x
mergeWith() Str→Int 624.6 ms 629.8 ms ~1.0x
forEach() Int→Int 41.1 ms 37.1 ms 0.9x
filter() Int→Int 93.8 ms 79.1 ms 0.8x
map() Int→Int 112.9 ms 110.4 ms ~1.0x
forEach() Str→Int 129.2 ms 122.1 ms 0.9x
filter() Str→Int 283.7 ms 241.9 ms 0.9x
map() Str→Int 354.4 ms 352.7 ms ~1.0x

Core Types (Windows, PHP 8.5)

Speedup = PHP time / Judy time. Bold = Judy faster.

Type Op Judy PHP array Speedup
Bitset Write 106.4 ms 12.0 ms 0.1x
Bitset Read 20.1 ms 8.3 ms 0.4x
Bitset Iter 28.5 ms 7.6 ms 0.3x
Bitset Free 0.01 ms 0.56 ms 39.9x
Int to Int Write 77.8 ms 11.9 ms 0.2x
Int to Int Read 25.6 ms 8.3 ms 0.3x
Int to Int Iter 31.0 ms 7.1 ms 0.2x
Int to Int Free 1.2 ms 0.56 ms 0.5x
Int to Mixed Write 101.0 ms 16.3 ms 0.2x
Int to Mixed Read 28.2 ms 9.8 ms 0.3x
Int to Mixed Iter 33.9 ms 8.1 ms 0.2x
Int to Mixed Free 34.4 ms 5.2 ms 0.2x
String to Int Write 234.5 ms 25.4 ms 0.1x
String to Int Read 81.4 ms 12.2 ms 0.1x
String to Int Iter 114.2 ms 8.6 ms 0.1x
String to Int Free 43.0 ms 1.8 ms 0.0x
String to Int (Adaptive) Write 367.3 ms 24.8 ms 0.1x
String to Int (Adaptive) Read 60.9 ms 11.9 ms 0.2x
String to Int (Adaptive) Iter 175.2 ms 8.1 ms 0.0x
String to Int (Adaptive) Free 97.3 ms 1.8 ms 0.0x
All types detail

Core Types (Windows, PHP 8.5) — All

Speedup = PHP time / Judy time. Bold = Judy faster.

Type Op Judy PHP array Speedup
Bitset Write 106.4 ms 12.0 ms 0.1x
Bitset Read 20.1 ms 8.3 ms 0.4x
Bitset Iter 28.5 ms 7.6 ms 0.3x
Bitset Free 0.01 ms 0.56 ms 39.9x
Int to Int Write 77.8 ms 11.9 ms 0.2x
Int to Int Read 25.6 ms 8.3 ms 0.3x
Int to Int Iter 31.0 ms 7.1 ms 0.2x
Int to Int Free 1.2 ms 0.56 ms 0.5x
Int to Mixed Write 101.0 ms 16.3 ms 0.2x
Int to Mixed Read 28.2 ms 9.8 ms 0.3x
Int to Mixed Iter 33.9 ms 8.1 ms 0.2x
Int to Mixed Free 34.4 ms 5.2 ms 0.2x
Int to Packed Write 119.2 ms 16.3 ms 0.1x
Int to Packed Read 58.8 ms 9.8 ms 0.2x
Int to Packed Iter 63.7 ms 8.1 ms 0.1x
Int to Packed Free 28.7 ms 5.3 ms 0.2x
String to Int Write 234.5 ms 25.4 ms 0.1x
String to Int Read 81.4 ms 12.2 ms 0.1x
String to Int Iter 114.2 ms 8.6 ms 0.1x
String to Int Free 43.0 ms 1.8 ms 0.0x
String to Mixed Write 281.1 ms 28.5 ms 0.1x
String to Mixed Read 82.5 ms 14.2 ms 0.2x
String to Mixed Iter 126.8 ms 9.1 ms 0.1x
String to Mixed Free 145.8 ms 8.3 ms 0.1x
String to Int (Hash) Write 414.1 ms 25.3 ms 0.1x
String to Int (Hash) Read 63.5 ms 12.7 ms 0.2x
String to Int (Hash) Iter 176.9 ms 8.6 ms 0.0x
String to Int (Hash) Free 100.1 ms 1.8 ms 0.0x
String to Mixed (Hash) Write 566.9 ms 28.4 ms 0.1x
String to Mixed (Hash) Read 65.4 ms 14.5 ms 0.2x
String to Mixed (Hash) Iter 202.6 ms 9.8 ms 0.0x
String to Mixed (Hash) Free 287.0 ms 8.3 ms 0.0x
String to Int (Adaptive) Write 367.3 ms 24.8 ms 0.1x
String to Int (Adaptive) Read 60.9 ms 11.9 ms 0.2x
String to Int (Adaptive) Iter 175.2 ms 8.1 ms 0.0x
String to Int (Adaptive) Free 97.3 ms 1.8 ms 0.0x
String to Mixed (Adaptive) Write 580.3 ms 28.1 ms 0.0x
String to Mixed (Adaptive) Read 63.5 ms 14.1 ms 0.2x
String to Mixed (Adaptive) Iter 212.4 ms 9.8 ms 0.0x
String to Mixed (Adaptive) Free 296.9 ms 7.9 ms 0.0x

Release Comparison (2.3.0 → 2.4.0)

Baseline: v2.3.0 via pie install on same CI runner. Comparing Linux PHP 8.5. Threshold: ±10% (entries < 2 ms ignored).

Summary: 5 faster, ⚠️ 1 regressions, 14 unchanged, 50 new

Benchmark Baseline Current Delta Status
core.bitset.free 0.01 ms 0.01 ms 0.0% ~same
core.bitset.iter 123.4 ms 18.4 ms -85.1% FASTER
core.bitset.read 12.7 ms 12.6 ms -0.2% ~same
core.bitset.write 22.4 ms 20.6 ms -7.7% ~same
core.int_to_int.free 0.33 ms 0.21 ms 0.0% ~same
core.int_to_int.iter 124.3 ms 20.0 ms -83.9% FASTER
core.int_to_int.read 14.5 ms 14.7 ms +1.4% ~same
core.int_to_int.write 24.9 ms 29.8 ms +19.5% ⚠️ SLOWER
core.int_to_mixed.free 16.0 ms 15.0 ms -6.1% ~same
core.int_to_mixed.iter 128.3 ms 21.3 ms -83.4% FASTER
core.int_to_mixed.read 17.1 ms 17.6 ms +2.9% ~same
core.int_to_mixed.write 42.3 ms 39.5 ms -6.6% ~same
core.string_to_int.free 24.3 ms 22.9 ms -5.7% ~same
core.string_to_int.iter 220.5 ms 63.7 ms -71.1% FASTER
core.string_to_int.read 45.4 ms 41.6 ms -8.3% ~same
core.string_to_int.write 108.0 ms 103.0 ms -4.6% ~same
core.string_to_mixed.free 81.0 ms 76.5 ms -5.6% ~same
core.string_to_mixed.iter 237.7 ms 70.4 ms -70.4% FASTER
core.string_to_mixed.read 48.7 ms 44.5 ms -8.7% ~same
core.string_to_mixed.write 136.2 ms 125.5 ms -7.9% ~same

Memory Comparison

Memory: ⚠️ 3 regressions, 2 unchanged

Type Baseline Current Delta Status
Bitset 128 B 160 B +25.0% ⚠️ WORSE
Int to Int 128 B 160 B +25.0% ⚠️ WORSE
Int to Mixed 7.6 MB 7.6 MB 0.0% ~same
String to Int 128 B 64.2 KB +51225.0% ⚠️ WORSE
String to Mixed 7.6 MB 7.7 MB +0.8% ~same
50 new benchmarks (not in baseline)
Benchmark Current
adv.filter.int_to_int 55.4 ms
adv.filter.string_to_int 148.3 ms
adv.forEach.int_to_int 27.7 ms
adv.forEach.string_to_int 75.0 ms
adv.map.int_to_int 58.3 ms
adv.map.string_to_int 174.3 ms
api.deleteRange.int_to_int 52.7 ms
api.equals.int_to_int 13.7 ms
api.fromArray.int_to_int 25.9 ms
api.getAll.int_to_int 1.5 ms
api.increment.int_to_int 28.6 ms
api.keys.int_to_int 11.9 ms
api.mergeWith.int_to_int 68.0 ms
api.mergeWith.string_to_int 294.7 ms
api.populationCount.int_to_int 0.00 ms
api.putAll.int_to_int 26.1 ms
api.setop.diff.bitset 17.6 ms
api.setop.diff.int_to_int 22.6 ms
api.setop.diff.string_to_int 134.9 ms
api.setop.intersect.bitset 17.1 ms
api.setop.intersect.int_to_int 22.4 ms
api.setop.intersect.string_to_int 138.7 ms
api.setop.union.bitset 38.3 ms
api.setop.union.int_to_int 53.4 ms
api.setop.union.string_to_int 370.7 ms
api.setop.xor.bitset 35.6 ms
api.setop.xor.int_to_int 45.4 ms
api.sumValues.int_to_int 7.9 ms
api.toArray.int_to_int 24.5 ms
api.values.int_to_int 11.7 ms
core.int_to_packed.free 10.9 ms
core.int_to_packed.iter 39.2 ms
core.int_to_packed.read 35.1 ms
core.int_to_packed.write 52.0 ms
core.string_to_int_adaptive.free 45.8 ms
core.string_to_int_adaptive.iter 78.6 ms
core.string_to_int_adaptive.read 26.9 ms
core.string_to_int_adaptive.write 160.6 ms
core.string_to_int_hash.free 44.8 ms
core.string_to_int_hash.iter 79.2 ms
core.string_to_int_hash.read 27.7 ms
core.string_to_int_hash.write 175.0 ms
core.string_to_mixed_adaptive.free 140.4 ms
core.string_to_mixed_adaptive.iter 92.8 ms
core.string_to_mixed_adaptive.read 29.0 ms
core.string_to_mixed_adaptive.write 259.7 ms
core.string_to_mixed_hash.free 139.2 ms
core.string_to_mixed_hash.iter 95.6 ms
core.string_to_mixed_hash.read 31.0 ms
core.string_to_mixed_hash.write 261.0 ms
Full benchmark output

Linux — PHP 8.5

══════════════════════════════════════════════════════════════════════════════════════════
  php-judy Benchmark Suite — 500,000 elements, 7 iterations (median)
  PHP 8.5.3 | Judy ext 2.4.0 | Linux x86_64
  Suite: all
══════════════════════════════════════════════════════════════════════════════════════════

── Core: Integer-Keyed Types ────────────────────────────────────────────────

  Type                         Write(ms)      Read(ms)      Iter(ms)      Free(ms)          Heap
  ────────────────────────  ────────────  ────────────  ────────────  ────────────  ────────────
  BITSET                           20.63         12.63         18.38          0.01         160 B
    PHP array                       7.37          3.90          3.11          0.35        8.0 MB
  INT_TO_INT                       29.80         14.70         19.96          0.21         160 B
    PHP array                       7.42          3.91          3.14          0.36        8.0 MB
  INT_TO_MIXED                     39.48         17.65         21.27         15.04        7.6 MB
    PHP array                      10.94          5.62          3.63          4.50        8.0 MB
  INT_TO_PACKED                    52.04         35.12         39.21         10.90       13.3 MB
    PHP array                      10.17          5.67          3.63          4.55        8.0 MB

── Core: String-Keyed Types ────────────────────────────────────────────────

  Type                         Write(ms)      Read(ms)      Iter(ms)      Free(ms)          Heap
  ────────────────────────  ────────────  ────────────  ────────────  ────────────  ────────────
  STRING_TO_INT                   103.00         41.65         63.68         22.89       64.2 KB
    PHP array                      16.83          7.34          4.58          1.38       20.0 MB
  STRING_TO_MIXED                 125.53         44.47         70.44         76.47        7.7 MB
    PHP array                      20.73          9.68          6.10          7.97       20.0 MB
  STR_TO_INT_HASH                 174.97         27.73         79.15         44.78       64.2 KB
    PHP array                      16.96          7.31          4.60          1.41       20.0 MB
  STR_TO_MIX_HASH                 260.97         31.03         95.59        139.22        7.7 MB
    PHP array                      20.50          9.70          6.39          7.55       20.0 MB
  STR_INT_ADAPTIVE                160.59         26.88         78.63         45.80       64.2 KB
    PHP array                      16.97          7.29          4.60          1.46       20.0 MB
  STR_MIX_ADAPTIVE                259.67         29.04         92.79        140.43        7.7 MB
    PHP array                      20.92          9.68          6.32          8.71       20.0 MB

── API: Batch Operations (INT_TO_INT) ────────────────────────────────────────

  Operation                           Judy(ms)       PHP(ms)     Speedup
  ──────────────────────────────  ────────────  ────────────  ──────────
  putAll()                               26.13         35.92        1.4x
  fromArray()                            25.88         35.92        1.4x
  toArray()                              24.51         38.60        1.6x
  getAll(50100 keys)                      1.46          2.30        1.6x
  increment(500000 ops/1000 keys)         28.59         10.17        0.4x

── API: Native Methods (keys, values, sum, popCount, deleteRange, equals) ────

  Operation                           Judy(ms)       PHP(ms)     Speedup
  ──────────────────────────────  ────────────  ────────────  ──────────
  keys() INT_TO_INT                      11.90         24.97        2.1x
  values() INT_TO_INT                    11.74         24.72        2.1x
  sumValues() INT_TO_INT                  7.92         19.31        2.4x
  populationCount() INT_TO_INT            0.00         19.95   249417.7x
  deleteRange() INT_TO_INT mid50%         52.73         69.81        1.3x
  equals() INT_TO_INT                    13.73         53.59        3.9x

── API: Set Operations (BITSET, 50% overlap) ────────────────────────────────

  Operation                           Judy(ms)       PHP(ms)     Speedup
  ──────────────────────────────  ────────────  ────────────  ──────────
  union() BITSET                         38.27          4.98        0.1x
  intersect() BITSET                     17.10          5.78        0.3x
  diff() BITSET                          17.64          3.37        0.2x
  xor() BITSET                           35.58         12.01        0.3x
  union() INT_TO_INT                     53.38         95.44        1.8x
  intersect() INT_TO_INT                 22.38         45.95        2.1x
  diff() INT_TO_INT                      22.58         47.61        2.1x
  xor() INT_TO_INT                       45.43         95.45        2.1x
  union() STRING_TO_INT                 370.69        356.41        1.0x
  intersect() STRING_TO_INT             138.68        156.25        1.1x
  diff() STRING_TO_INT                  134.92        154.03        1.1x
  mergeWith() INT_TO_INT                 68.01         75.49        1.1x
  mergeWith() STRING_TO_INT             294.68        285.13        1.0x

── Advanced: C-Level forEach/filter/map ──────────────────────────────────────

  Operation                        C-level(ms)       PHP(ms)     Speedup
  ──────────────────────────────  ────────────  ────────────  ──────────
  forEach() INT_TO_INT                   27.73         22.89        0.8x
  forEach() STRING_TO_INT                74.97         65.46        0.9x
  filter() INT_TO_INT (50% pass)         55.40         43.57        0.8x
  filter() STRING_TO_INT (50% pass)        148.34        120.64        0.8x
  map() INT_TO_INT (*2)                  58.30         55.10        0.9x
  map() STRING_TO_INT (*2)              174.30        170.82        1.0x

── Advanced: Adaptive SSO — short keys (<8 bytes) via JudyL ─────────────────

  Operation                   STR_TO_INT    STR_INT_HASH   STR_INT_ADPTV    Best ratio
  ──────────────────────  ──────────────  ──────────────  ──────────────  ────────────
  insert (short keys)          76.93 ms      132.13 ms      112.45 ms       1.7x
  read (random access)         12.24 ms       12.80 ms       12.01 ms       1.1x
  foreach (iterate all)        48.41 ms       76.06 ms       78.20 ms       1.6x

── Advanced: Adaptive SSO — long keys (>=8 bytes) fallback to JudyHS ────────

  Operation                   STR_TO_INT    STR_INT_HASH   STR_INT_ADPTV    Best ratio
  ──────────────────────  ──────────────  ──────────────  ──────────────  ────────────
  insert (long keys)          128.53 ms      227.16 ms      206.57 ms       1.8x
  read (random access)         44.72 ms       37.80 ms       39.48 ms       1.2x
  foreach (iterate all)        98.69 ms      114.28 ms      112.58 ms       1.2x

══════════════════════════════════════════════════════════════════════════════════════════
  Benchmark complete — 2026-03-03 07:16:06
  All timings: median of 7 iterations via hrtime(true), 1 warmup run
══════════════════════════════════════════════════════════════════════════════════════════

  JSON results written to: bench.json

Windows — PHP 8.5

══════════════════════════════════════════════════════════════════════════════════════════
  php-judy Benchmark Suite — 500,000 elements, 7 iterations (median)
  PHP 8.5.3 | Judy ext 2.4.0 | WINNT AMD64
  Suite: all
══════════════════════════════════════════════════════════════════════════════════════════

── Core: Integer-Keyed Types ────────────────────────────────────────────────

  Type                         Write(ms)      Read(ms)      Iter(ms)      Free(ms)          Heap
  ────────────────────────  ────────────  ────────────  ────────────  ────────────  ────────────
  BITSET                          106.40         20.14         28.49          0.01         160 B
    PHP array                      12.03          8.31          7.56          0.56       10.0 MB
  INT_TO_INT                       77.75         25.57         31.04          1.21         160 B
    PHP array                      11.93          8.34          7.07          0.56       10.0 MB
  INT_TO_MIXED                    100.97         28.18         33.95         34.37        7.6 MB
    PHP array                      16.31          9.78          8.11          5.21       10.0 MB
  INT_TO_PACKED                   119.18         58.82         63.66         28.68       13.3 MB
    PHP array                      16.25          9.78          8.13          5.32       10.0 MB

── Core: String-Keyed Types ────────────────────────────────────────────────

  Type                         Write(ms)      Read(ms)      Iter(ms)      Free(ms)          Heap
  ────────────────────────  ────────────  ────────────  ────────────  ────────────  ────────────
  STRING_TO_INT                   234.53         81.41        114.23         43.05       64.2 KB
    PHP array                      25.43         12.20          8.57          1.83       20.0 MB
  STRING_TO_MIXED                 281.13         82.46        126.82        145.84        7.7 MB
    PHP array                      28.47         14.16          9.12          8.33       20.0 MB
  STR_TO_INT_HASH                 414.14         63.53        176.94        100.14       64.2 KB
    PHP array                      25.29         12.66          8.55          1.83       20.0 MB
  STR_TO_MIX_HASH                 566.91         65.44        202.65        287.01        7.7 MB
    PHP array                      28.40         14.45          9.76          8.34       20.0 MB
  STR_INT_ADAPTIVE                367.31         60.91        175.25         97.33       64.2 KB
    PHP array                      24.84         11.88          8.08          1.84       20.0 MB
  STR_MIX_ADAPTIVE                580.30         63.49        212.44        296.90        7.7 MB
    PHP array                      28.06         14.09          9.82          7.91       20.0 MB

── API: Batch Operations (INT_TO_INT) ────────────────────────────────────────

  Operation                           Judy(ms)       PHP(ms)     Speedup
  ──────────────────────────────  ────────────  ────────────  ──────────
  putAll()                               74.56         88.59        1.2x
  fromArray()                            74.16         88.59        1.2x
  toArray()                              80.37        101.04        1.3x
  getAll(50100 keys)                      2.64          3.84        1.5x
  increment(500000 ops/1000 keys)         57.15         23.87        0.4x

── API: Native Methods (keys, values, sum, popCount, deleteRange, equals) ────

  Operation                           Judy(ms)       PHP(ms)     Speedup
  ──────────────────────────────  ────────────  ────────────  ──────────
  keys() INT_TO_INT                      22.63         39.37        1.7x
  values() INT_TO_INT                    23.02         39.72        1.7x
  sumValues() INT_TO_INT                 17.49         32.56        1.9x
  populationCount() INT_TO_INT            0.00         33.47   334716.0x
  deleteRange() INT_TO_INT mid50%        140.44        162.87        1.2x
  equals() INT_TO_INT                    31.76         85.95        2.7x

── API: Set Operations (BITSET, 50% overlap) ────────────────────────────────

  Operation                           Judy(ms)       PHP(ms)     Speedup
  ──────────────────────────────  ────────────  ────────────  ──────────
  union() BITSET                        184.65          8.91        0.0x
  intersect() BITSET                     72.78          7.62        0.1x
  diff() BITSET                          70.72          4.19        0.1x
  xor() BITSET                          143.99         17.29        0.1x
  union() INT_TO_INT                    149.10        206.01        1.4x
  intersect() INT_TO_INT                 56.51         88.21        1.6x
  diff() INT_TO_INT                      55.25         91.10        1.6x
  xor() INT_TO_INT                      112.34        185.52        1.7x
  union() STRING_TO_INT                 767.83        755.17        1.0x
  intersect() STRING_TO_INT             299.84        324.05        1.1x
  diff() STRING_TO_INT                  284.16        311.43        1.1x
  mergeWith() INT_TO_INT                168.02        173.10        1.0x
  mergeWith() STRING_TO_INT             624.57        629.80        1.0x

── Advanced: C-Level forEach/filter/map ──────────────────────────────────────

  Operation                        C-level(ms)       PHP(ms)     Speedup
  ──────────────────────────────  ────────────  ────────────  ──────────
  forEach() INT_TO_INT                   41.10         37.10        0.9x
  forEach() STRING_TO_INT               129.19        122.07        0.9x
  filter() INT_TO_INT (50% pass)         93.84         79.11        0.8x
  filter() STRING_TO_INT (50% pass)        283.67        241.85        0.9x
  map() INT_TO_INT (*2)                 112.88        110.44        1.0x
  map() STRING_TO_INT (*2)              354.44        352.66        1.0x

── Advanced: Adaptive SSO — short keys (<8 bytes) via JudyL ─────────────────

  Operation                   STR_TO_INT    STR_INT_HASH   STR_INT_ADPTV    Best ratio
  ──────────────────────  ──────────────  ──────────────  ──────────────  ────────────
  insert (short keys)         173.39 ms      310.49 ms      263.76 ms       1.8x
  read (random access)         22.14 ms       23.71 ms       21.12 ms       1.1x
  foreach (iterate all)        85.81 ms      144.08 ms      130.61 ms       1.7x

── Advanced: Adaptive SSO — long keys (>=8 bytes) fallback to JudyHS ────────

  Operation                   STR_TO_INT    STR_INT_HASH   STR_INT_ADPTV    Best ratio
  ──────────────────────  ──────────────  ──────────────  ──────────────  ────────────
  insert (long keys)          301.15 ms      533.04 ms      468.01 ms       1.8x
  read (random access)         45.56 ms       38.33 ms       42.20 ms       1.2x
  foreach (iterate all)       185.09 ms      271.37 ms      307.33 ms       1.5x

══════════════════════════════════════════════════════════════════════════════════════════
  Benchmark complete — 2026-03-03 07:17:55
  All timings: median of 7 iterations via hrtime(true), 1 warmup run
══════════════════════════════════════════════════════════════════════════════════════════

  JSON results written to: bench.json

- Add missing `mixed` type hint to judy_type() in Judy.stub.php
  (aligns stub signature with its @param mixed PHPDoc tag; regenerates
  API.md and Judy_arginfo.h accordingly)
- Add mb_strlen() fallback in generate-api-docs.php via str_width()
  helper (gracefully handles environments where mbstring is not loaded)
@orieg orieg merged commit d258bee into main Mar 3, 2026
13 checks passed
@orieg orieg deleted the docs/automate-api-docs-generation branch March 3, 2026 07:26
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.

1 participant