@@ -365,8 +365,7 @@ public function testDistributedPoolManagerMock(): void
365365
366366 /**
367367 * Test end-to-end high-performance scenario
368- */
369- /**
368+ *
370369 * @group performance
371370 */
372371 public function testEndToEndHighPerformanceScenario (): void
@@ -421,8 +420,13 @@ function ($req, $res) {
421420 $ duration = microtime (true ) - $ startTime ;
422421 $ throughput = count ($ results ) / $ duration ;
423422
424- // Verify performance (adjusted for CI environment)
425- $ this ->assertGreaterThan (10 , $ throughput , 'Should handle >10 req/s ' );
423+ // Verify performance with environment-aware threshold
424+ $ threshold = $ this ->getPerformanceThreshold ();
425+ $ this ->assertGreaterThan (
426+ $ threshold ,
427+ $ throughput ,
428+ sprintf ('Should handle >%d req/s (actual: %.2f req/s) ' , $ threshold , $ throughput )
429+ );
426430
427431 // Check monitoring data
428432 $ monitor = HighPerformanceMode::getMonitor ();
@@ -441,6 +445,33 @@ function ($req, $res) {
441445 $ this ->assertTrue (true , 'High-performance scenario completed successfully ' );
442446 }
443447
448+ /**
449+ * Get performance threshold based on environment
450+ *
451+ * This method provides environment-aware performance thresholds to avoid
452+ * masking performance regressions while accounting for CI constraints.
453+ *
454+ * @return int The minimum throughput threshold in requests/second
455+ */
456+ private function getPerformanceThreshold (): int
457+ {
458+ // Check if running in CI environment
459+ if (getenv ('CI ' ) !== false || getenv ('GITHUB_ACTIONS ' ) !== false ) {
460+ // CI environments are typically constrained
461+ // Use lower threshold but still meaningful for regression detection
462+ return 25 ; // CI threshold: 25 req/s
463+ }
464+
465+ // Check if running in Docker or containerized environment
466+ if (file_exists ('/.dockerenv ' ) || getenv ('DOCKER ' ) !== false ) {
467+ // Docker environments may have resource constraints
468+ return 50 ; // Docker threshold: 50 req/s
469+ }
470+
471+ // Local development environment - expect full performance
472+ return 100 ; // Local threshold: 100 req/s
473+ }
474+
444475 protected function tearDown (): void
445476 {
446477 parent ::tearDown ();
0 commit comments