k-samuel / optimize-me
Code optimization challenge for PHP developers
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=7.4.0
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2024-11-23 09:52:41 UTC
README
OptimizeMe Challenge
Code optimization challenge for PHP developers.
PHP modified adaptation. Based on homework task for Golang educational project with Romanov Vasily “Technosphere Mail.ru Group” at Moscow State University. Lomonosov.
Introduction
Task for working with the xdebug
profiler.
There is a Search method that parses the file and displays the necessary data. It doesn't fast enough. It is necessary to optimize the code of this method.
Target
Learn to work with xdebug profiler, find hot spots in the code, be able to build a profile CPU and memory consumption, optimize the code taking this information into account.
Task
Using xdebug profile optimize the search method. The source code of the method is located in the file src/Slow/Search.php, the new implementation should be written in the file src/Fast/Search.php.
You can run the benchmark in the root of the project directory php bench.php
To complete the task, need to optimize each param:
- Count (number of starts in 1s): better then slow * 3
- Memory (peak RAM consumption): better then slow / 3
- Best Time (fastest time for one pass): better then slow / 3
Install
Run composer create-project k-samuel/optimize-me
Benchmark
Run php bench.php
Note: Memory consumption statistics accessible only for PHP >= 8.2
Expected results
Try to get comparable (or better) results. Please note that performance is highly dependent on your hardware and results may vary.
PHP 8.2 + opcache + JIT, apple M2