forked from PHP/Router
Move flag logic to test tools script
This commit is contained in:
parent
44ad5c5512
commit
327981e72e
|
@ -8,11 +8,6 @@
|
|||
The requests are randomly picked from the array of routes.
|
||||
*/
|
||||
|
||||
// if there's a flag, reset the opcache
|
||||
if (in_array('-f', $argv)) {
|
||||
opcache_reset();
|
||||
}
|
||||
|
||||
require_once 'tools.php';
|
||||
|
||||
$r = new SegmentRouter();
|
||||
|
@ -20,7 +15,8 @@ $r = new SegmentRouter();
|
|||
// Blog lookups
|
||||
$blog = readAndAddRoutes('blog.txt', $r);
|
||||
writeRoutesToFile($r->routes, 'storage/segment/blog.txt');
|
||||
echoTitle("Starting github lookups");
|
||||
echoTitle("Starting blog lookups");
|
||||
runIterations(10000, $r, $blog);
|
||||
runIterations(100000, $r, $blog);
|
||||
runIterations(1000000, $r, $blog);
|
||||
unset($blog);
|
||||
|
|
|
@ -8,11 +8,6 @@
|
|||
The requests are randomly picked from the array of routes.
|
||||
*/
|
||||
|
||||
// if there's a flag, reset the opcache
|
||||
if (in_array('-f', $argv)) {
|
||||
opcache_reset();
|
||||
}
|
||||
|
||||
require_once 'tools.php';
|
||||
require_once __DIR__ . '/../SimpleRouter.php';
|
||||
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
<?php
|
||||
|
||||
// if there's a flag, reset the opcache
|
||||
if (in_array('-f', $argv)) {
|
||||
opcache_reset();
|
||||
echoTitle("opcache reset");
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../Router.php';
|
||||
require_once __DIR__ . '/../SegmentRouter.php';
|
||||
require_once __DIR__ . '/../TrieRouter.php';
|
||||
|
@ -107,10 +113,13 @@ function runIterations(int $iterations, $r, array $routes) {
|
|||
for ($i = 0; $i < $iterations; $i++) {
|
||||
// pick a random route from the array
|
||||
[$method, $path] = $routes[array_rand($routes)];
|
||||
/*
|
||||
// replace all :params/ with random values
|
||||
$uri = preg_replace_callback('/:(\w+)/', function($matches) {
|
||||
return rand(1, 100);
|
||||
}, $path);
|
||||
*/
|
||||
$uri = $path;
|
||||
$start2 = microtime(true);
|
||||
$res = $r->lookup($method, $uri);
|
||||
if ($res === 404 || $res === 405) {
|
||||
|
|
|
@ -8,11 +8,6 @@
|
|||
The requests are randomly picked from the array of routes.
|
||||
*/
|
||||
|
||||
// if there's a flag, reset the opcache
|
||||
if (in_array('-f', $argv)) {
|
||||
opcache_reset();
|
||||
}
|
||||
|
||||
require_once 'tools.php';
|
||||
|
||||
$r = new TrieRouter();
|
||||
|
|
Loading…
Reference in New Issue
Block a user