configured performance testing

api-security v3.17.2
n0nag0n 1 week ago
parent c9da0675d9
commit 095a46663f

@ -68,6 +68,15 @@
"test-server": "echo \"Running Test Server\" && php -S localhost:8000 -t tests/server/", "test-server": "echo \"Running Test Server\" && php -S localhost:8000 -t tests/server/",
"test-server-v2": "echo \"Running Test Server\" && php -S localhost:8000 -t tests/server-v2/", "test-server-v2": "echo \"Running Test Server\" && php -S localhost:8000 -t tests/server-v2/",
"test-coverage:win": "del clover.xml && phpunit --coverage-html=coverage --coverage-clover=clover.xml && coverage-check clover.xml 100", "test-coverage:win": "del clover.xml && phpunit --coverage-html=coverage --coverage-clover=clover.xml && coverage-check clover.xml 100",
"test-performance": [
"echo \"Running Performance Tests...\"",
"php -S localhost:8077 -t tests/performance/ > /dev/null 2>&1 & echo $! > server.pid",
"sleep 2",
"bash tests/performance/performance_tests.sh",
"kill `cat server.pid`",
"rm server.pid",
"echo \"Performance Tests Completed.\""
],
"lint": "phpstan --no-progress --memory-limit=256M -cphpstan.neon", "lint": "phpstan --no-progress --memory-limit=256M -cphpstan.neon",
"beautify": "phpcbf --standard=phpcs.xml", "beautify": "phpcbf --standard=phpcs.xml",
"phpcs": "phpcs --standard=phpcs.xml -n", "phpcs": "phpcs --standard=phpcs.xml -n",

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/../../vendor/autoload.php';
// Route to list all available test routes // Route to list all available test routes
Flight::route('GET /', function () { Flight::route('GET /', function () {

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Allow URL to be set via environment variable or first command-line argument, default to localhost for safety # Allow URL to be set via environment variable or first command-line argument, default to localhost for safety
URL="${URL:-${1:-http://localhost:8080/test-static}}" URL="${URL:-${1:-http://localhost:8077/test-static}}"
REQUESTS=1000 REQUESTS=1000
CONCURRENCY=10 CONCURRENCY=10
ITERATIONS=10 ITERATIONS=10
@ -30,6 +30,11 @@ for i in $(seq 1 $ITERATIONS); do
time_per_request=$(echo "$result" | grep "Time per request:" | head -1 | awk '{print $4}') time_per_request=$(echo "$result" | grep "Time per request:" | head -1 | awk '{print $4}')
requests_per_sec=$(echo "$result" | grep "Requests per second:" | awk '{print $4}') requests_per_sec=$(echo "$result" | grep "Requests per second:" | awk '{print $4}')
if [[ -z "$time_per_request" || ! "$time_per_request" =~ ^[0-9.]+$ ]]; then
echo "Warning: Could not parse time per request (ab output may be malformed)"
continue
fi
times+=($time_per_request) times+=($time_per_request)
total=$(echo "$total + $time_per_request" | bc -l) total=$(echo "$total + $time_per_request" | bc -l)

Loading…
Cancel
Save