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.
|
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 'tools.php';
|
||||||
|
|
||||||
$r = new SegmentRouter();
|
$r = new SegmentRouter();
|
||||||
|
@ -20,7 +15,8 @@ $r = new SegmentRouter();
|
||||||
// Blog lookups
|
// Blog lookups
|
||||||
$blog = readAndAddRoutes('blog.txt', $r);
|
$blog = readAndAddRoutes('blog.txt', $r);
|
||||||
writeRoutesToFile($r->routes, 'storage/segment/blog.txt');
|
writeRoutesToFile($r->routes, 'storage/segment/blog.txt');
|
||||||
echoTitle("Starting github lookups");
|
echoTitle("Starting blog lookups");
|
||||||
|
runIterations(10000, $r, $blog);
|
||||||
runIterations(100000, $r, $blog);
|
runIterations(100000, $r, $blog);
|
||||||
runIterations(1000000, $r, $blog);
|
runIterations(1000000, $r, $blog);
|
||||||
unset($blog);
|
unset($blog);
|
||||||
|
|
|
@ -8,11 +8,6 @@
|
||||||
The requests are randomly picked from the array of routes.
|
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 'tools.php';
|
||||||
require_once __DIR__ . '/../SimpleRouter.php';
|
require_once __DIR__ . '/../SimpleRouter.php';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
<?php
|
<?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__ . '/../Router.php';
|
||||||
require_once __DIR__ . '/../SegmentRouter.php';
|
require_once __DIR__ . '/../SegmentRouter.php';
|
||||||
require_once __DIR__ . '/../TrieRouter.php';
|
require_once __DIR__ . '/../TrieRouter.php';
|
||||||
|
@ -107,10 +113,13 @@ function runIterations(int $iterations, $r, array $routes) {
|
||||||
for ($i = 0; $i < $iterations; $i++) {
|
for ($i = 0; $i < $iterations; $i++) {
|
||||||
// pick a random route from the array
|
// pick a random route from the array
|
||||||
[$method, $path] = $routes[array_rand($routes)];
|
[$method, $path] = $routes[array_rand($routes)];
|
||||||
|
/*
|
||||||
// replace all :params/ with random values
|
// replace all :params/ with random values
|
||||||
$uri = preg_replace_callback('/:(\w+)/', function($matches) {
|
$uri = preg_replace_callback('/:(\w+)/', function($matches) {
|
||||||
return rand(1, 100);
|
return rand(1, 100);
|
||||||
}, $path);
|
}, $path);
|
||||||
|
*/
|
||||||
|
$uri = $path;
|
||||||
$start2 = microtime(true);
|
$start2 = microtime(true);
|
||||||
$res = $r->lookup($method, $uri);
|
$res = $r->lookup($method, $uri);
|
||||||
if ($res === 404 || $res === 405) {
|
if ($res === 404 || $res === 405) {
|
||||||
|
|
|
@ -8,11 +8,6 @@
|
||||||
The requests are randomly picked from the array of routes.
|
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 'tools.php';
|
||||||
|
|
||||||
$r = new TrieRouter();
|
$r = new TrieRouter();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user