Code Monkey home page Code Monkey logo

php-router-benchmark's People

Contributors

c9s avatar realityking avatar stof avatar tyler-sommer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

php-router-benchmark's Issues

Unrealistic benchmark scenarios: ignoring initialization

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.

FastRoute benchmark is not precise...?

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?

can not install "pux" by using composer.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.