Skip to content

Conversation

@kamil-tekiela
Copy link

@kamil-tekiela kamil-tekiela commented Jan 20, 2026

This should optimise the performance of this method by 10x. Regex is much more suitable for a task like this than a loop which reconstructs the string character by character. ucfirst is twice as fast as strtoupper with character substitution. Since this is hot code, the optimisation has a significant impact on the runtime.

One behavioural change is that the second regex also skips the digits at the start of the string. Since the return value is trimmed, it makes sense not to add a space at the beginning of the string.

@sebastianbergmann sebastianbergmann added feature/testdox The TextDox printer/formatter type/performance Issues related to resource consumption (time and memory) labels Jan 20, 2026
@kamil-tekiela kamil-tekiela force-pushed the Optimize-prettifyTestMethodName branch from d3ebf9c to 271c88a Compare January 20, 2026 16:43
@staabm
Copy link
Contributor

staabm commented Jan 20, 2026

Please share how you benchmark it

@kamil-tekiela
Copy link
Author

Please share how you benchmark it

Using a very simple handwritten benchmark. https://3v4l.org/iH2iu/rfc#vgit.master

I have also verified that there is an impact by executing the change with phpMyAdmin's test suite.

image image

I am sure you can verify the changes much more scientifically.

@staabm
Copy link
Contributor

staabm commented Jan 21, 2026

I don't need a scientific one.

How much does it speedup end-to-end on phpMyAdmin?

Thank you

@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.01%. Comparing base (1aba907) to head (271c88a).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6474      +/-   ##
============================================
- Coverage     96.01%   96.01%   -0.01%     
+ Complexity     7352     7343       -9     
============================================
  Files           798      798              
  Lines         22627    22619       -8     
============================================
- Hits          21726    21718       -8     
  Misses          901      901              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature/testdox The TextDox printer/formatter type/performance Issues related to resource consumption (time and memory)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants