- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
79 lines
3.0 KiB
PHP
79 lines
3.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
echo "🧪 Minimal Discovery Performance Test\n";
|
|
echo "====================================\n\n";
|
|
|
|
// Measure discovery service bootstrap times directly
|
|
$iterations = 3;
|
|
$times = [];
|
|
|
|
for ($i = 1; $i <= $iterations; $i++) {
|
|
echo "Run $i: ";
|
|
|
|
$startTime = microtime(true);
|
|
|
|
// Simulate what happens in the real bootstrap
|
|
$output = shell_exec('docker exec php php -r "
|
|
require_once \"/var/www/html/vendor/autoload.php\";
|
|
use App\\Framework\\Core\\AppBootstrapper;
|
|
use App\\Framework\\Performance\\PerformanceCollector;
|
|
use App\\Framework\\Performance\\MemoryMonitor;
|
|
|
|
// Simple mock objects
|
|
class SimplePerformanceCollector implements App\\Framework\\Performance\\Contracts\\PerformanceCollectorInterface {
|
|
public function startTiming(string \$operation, ?App\\Framework\\Performance\\PerformanceCategory \$category = null): void {}
|
|
public function endTiming(string \$operation): void {}
|
|
public function recordMetric(string \$name, float \$value, ?App\\Framework\\Performance\\PerformanceCategory \$category = null): void {}
|
|
public function getMetrics(): array { return []; }
|
|
public function clear(): void {}
|
|
}
|
|
|
|
class SimpleMemoryMonitor {
|
|
public function getCurrentUsage(): int { return memory_get_usage(); }
|
|
public function getPeakUsage(): int { return memory_get_peak_usage(); }
|
|
}
|
|
|
|
\$start = microtime(true);
|
|
\$collector = new SimplePerformanceCollector();
|
|
\$memoryMonitor = new SimpleMemoryMonitor();
|
|
\$bootstrapper = new AppBootstrapper(\"/var/www/html\", \$collector, \$memoryMonitor);
|
|
\$app = \$bootstrapper->bootstrapWeb();
|
|
\$end = microtime(true);
|
|
|
|
echo number_format((\$end - \$start) * 1000, 2) . \"ms\";
|
|
" 2>/dev/null');
|
|
|
|
$endTime = microtime(true);
|
|
$totalTime = ($endTime - $startTime) * 1000;
|
|
|
|
// Extract the bootstrap time from output
|
|
if (preg_match('/(\d+\.?\d*)ms/', $output, $matches)) {
|
|
$bootstrapTime = (float)$matches[1];
|
|
echo $bootstrapTime . "ms (bootstrap time)\n";
|
|
$times[] = $bootstrapTime;
|
|
} else {
|
|
echo "ERROR - could not measure\n";
|
|
echo "Output: " . trim($output) . "\n";
|
|
}
|
|
}
|
|
|
|
if (! empty($times)) {
|
|
echo "\n📊 Results:\n";
|
|
echo " Average: " . number_format(array_sum($times) / count($times), 2) . "ms\n";
|
|
echo " Min: " . number_format(min($times), 2) . "ms\n";
|
|
echo " Max: " . number_format(max($times), 2) . "ms\n";
|
|
|
|
$avgTime = array_sum($times) / count($times);
|
|
if ($avgTime > 3000) {
|
|
echo "\n❌ PROBLEM: Bootstrap taking > 3000ms\n";
|
|
echo "This indicates the Discovery Service cache is not working!\n";
|
|
} elseif ($avgTime > 500) {
|
|
echo "\n⚠️ WARNING: Bootstrap taking > 500ms\n";
|
|
echo "Cache might not be optimal.\n";
|
|
} else {
|
|
echo "\n✅ Good: Bootstrap time is acceptable\n";
|
|
}
|
|
}
|