veonik / php-router-benchmark Goto Github PK
View Code? Open in Web Editor NEWBenchmarks of different routing solutions
License: MIT License
Benchmarks of different routing solutions
License: MIT License
It's great that you went through the work of creating a real benchmark for this ๐
But, as with the original benchmark, I have to wonder if it's a realistic scenario. You're benchmarking the raw performance of simply resolving URLs in a loop. When is that going to happen in real life?
For most real-world scenarios, initialization and resolution is going to happen lock-step, e.g. resolution is going to happen once per request - which means that initialization is going to happen once per request.
This isn't NodeJS - the router doesn't sit around waiting, prepared for the next request; it needs to be initialized on every call. (and yes, I know about React, but the ordinary scenario is more likely Apache or FPM, etc.)
I think, for this benchmark to be relevant, initialization needs to happen in the benchmark loop.
For that matter, if this was to be totally realistic, you should run the routers in isolated scripts, using actual HTTP requests. I think it's fair to ignore overhead from autoloading etc. as it's likely going to have a marginal impact overall - but I don't think it's realistic to exclude initialization entirely?
Also note that Benchmark::execute() ought to dry-run the test once (execute without measuring) to trigger autoloaders etc. so this doesn't potentially skew the result of the first iteration.
Gone missing here: https://github.com/DASPRiD/Dash /cc @DASPRiD
Please update with:
Klein
AltoRouter
Hi there. First of all thanks for the benchmark. I was impressed by good performance of FastRoute and decided to look at worst-case-tests.php
I have played with it a bit and thought that it will be good idea to measure the time it takes by FastRoute to find a given route directly inside "setupFastRoute" function.
-----This is changes that I've made -----
function setupFastRoute(Benchmark $benchmark, $routes, $args)
{
$argString = implode('/', array_map(function ($i) { return "{arg$i}"; }, range(1, $args)));
$str = $firstStr = $lastStr = '';
$router = \FastRoute\simpleDispatcher(function ($router) use ($routes, $argString, &$lastStr) {
for ($i = 0; $i < $routes; $i++) {
list ($pre, $post) = getRandomParts();
$str = '/' . $pre . '/' . $argString . '/' . $post;
if (0 === $i) {
$firstStr = str_replace(array('{', '}'), '', $str);
}
$lastStr = str_replace(array('{', '}'), '', $str);
$router->addRoute('GET', $str, 'handler' . $i);
}
});
$start = microtime(true);
$route = $router->dispatch('GET', $lastStr);
echo microtime(true) - $start ;
}
and I am getting a surprisingly slow result of 0.0069520473480225
Do you think that something is wrong with FastRoute's benchmark?
The package tyler-sommer/nice-bench
used in this benchmark does not seem to exist anymore.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for corneltek/pux dev-master -> satisfiable by corneltek/pux[dev-master].
- corneltek/pux dev-master requires phpsgi/phpsgi dev-master -> no matching package found.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.