array:3 [ // laravel-serializable-closure://function (\Modules\SchedulingBooking\Services\AvailabilityService $availabilityService) { $serviceId = 678; // 5 минут $date = '2025-11-17'; $queryCount = 0; $queryTime = 0; \Illuminate\Support\Facades\DB::listen(function ($query) use (&$queryCount, &$queryTime) { $queryCount++; $queryTime += $query->time; }); $startMemory = \memory_get_usage(); $startTime = \microtime(true); // Сбрасываем счетчики перед тестом \Modules\SchedulingBooking\Services\IntervalCalculator::resetCounters(); $performanceLog = []; $service = \Modules\Services\Models\ClubService::with(['clubEmployees.employee', 'clubResources', 'club'])->find($serviceId); $date = \Illuminate\Support\Carbon::parse($date); $startOfDay = $date->copy()->startOfDay(); $endOfDay = $date->copy()->endOfDay(); $duration = 5; // Хардкодим для стресс-теста $employeeSet = $service->clubEmployees->all(); $resourceSet = $service->clubResources->all(); $otherParticipants = [$service, $service->club]; $availableSlotsWithData = $availabilityService->findAvailableSlotsForCombinations( $startOfDay, $endOfDay, $duration, $employeeSet, $resourceSet, $otherParticipants, $performanceLog // Передаем по ссылке ); // Добавляем данные из калькулятора в лог $performanceLog['calculator_subtract_calls'] = \Modules\SchedulingBooking\Services\IntervalCalculator::$subtractCalls; $performanceLog['calculator_subtract_total_ms'] = \round(\Modules\SchedulingBooking\Services\IntervalCalculator::$subtractTime * 1000); $performanceLog['calculator_intersect_calls'] = \Modules\SchedulingBooking\Services\IntervalCalculator::$intersectCalls; $performanceLog['calculator_intersect_total_ms'] = \round(\Modules\SchedulingBooking\Services\IntervalCalculator::$intersectTime * 1000); $performanceLog['calculator_merge_calls'] = \Modules\SchedulingBooking\Services\IntervalCalculator::$mergeCalls; $performanceLog['calculator_merge_total_ms'] = \round(\Modules\SchedulingBooking\Services\IntervalCalculator::$mergeTime * 1000); $performanceLog['calculator_split_calls'] = \Modules\SchedulingBooking\Services\IntervalCalculator::$splitCalls; $performanceLog['calculator_split_total_ms'] = \round(\Modules\SchedulingBooking\Services\IntervalCalculator::$splitTime * 1000); $endTime = \microtime(true); $endMemory = \memory_get_usage(); \dump([ 'performance' => [ 'total_time_ms' => \round(($endTime - $startTime) * 1000), 'memory_usage_mb' => \round(($endMemory - $startMemory) / 1024 / 1024, 2), 'peak_memory_mb' => \round(\memory_get_peak_usage() / 1024 / 1024, 2), 'db_queries' => $queryCount, 'db_time_ms' => \round($queryTime, 2), ], 'performance_breakdown' => $performanceLog, 'slots_found_raw' => \count($availableSlotsWithData), ]); }:48 "performance" => array:5 [ "total_time_ms" => 100.0 "memory_usage_mb" => 0.42 "peak_memory_mb" => 3.87 "db_queries" => 12 "db_time_ms" => 82.47 ] "performance_breakdown" => array:13 [ "1_preload_data_ms" => 72.0 "2_main_loop_total_ms" => 1.0 "3a_getNetFreeIntervals_total_ms" => 0.0 "3b_splitIntervalsIntoSlots_total_ms" => 1.0 "total_service_execution_ms" => 73.0 "calculator_subtract_calls" => 4 "calculator_subtract_total_ms" => 0.0 "calculator_intersect_calls" => 1 "calculator_intersect_total_ms" => 0.0 "calculator_merge_calls" => 3 "calculator_merge_total_ms" => 0.0 "calculator_split_calls" => 1 "calculator_split_total_ms" => 1.0 ] "slots_found_raw" => 63 ]