/** * @param \Symfony\Component\HttpKernel\Profiler\Profile $profile * @param \Symfony\Component\HttpFoundation\Request $request * * @return \Symfony\Component\HttpFoundation\JsonResponse */ public function savePerformanceTimingAction(Profile $profile, Request $request) { $this->profiler->disable(); $data = Json::decode($request->getContent()); /** @var $collector */ $collector = $profile->getCollector('performance_timing'); $collector->setData($data); $this->profiler->updateProfile($profile); return new JsonResponse(['success' => TRUE]); }
/** * Update the profiles with the timing info and saves them. * * @param Profile $profile The root profile * @param Boolean $updateChildren Whether to update the children altogether */ private function saveStopwatchInfoInProfile(Profile $profile, $updateChildren) { $profile->getCollector('time')->setEvents($this->stopwatch->getSectionEvents($profile->getToken())); $this->profiler->saveProfile($profile); if ($updateChildren) { foreach ($profile->getChildren() as $child) { $this->saveStopwatchInfoInProfile($child, true); } } }
/** * Exposes collector's data as JSON. * * @param \Symfony\Component\HttpKernel\Profiler\Profile $profile * @param $collector * * @return \Symfony\Component\HttpFoundation\JsonResponse */ public function restCollectorAction(Profile $profile, $collector) { $this->profiler->disable(); $data = $profile->getCollector($collector)->getData(); return new JsonResponse(['data' => $data]); }
/** * Update the profiles with the timing and events information and saves them. * * @param Profile $profile The root profile * @param Boolean $updateChildren Whether to update the children altogether */ private function saveInfoInProfile(Profile $profile, $updateChildren) { try { $collector = $profile->getCollector('memory'); $collector->updateMemoryUsage(); } catch (\InvalidArgumentException $e) { } try { $collector = $profile->getCollector('time'); $collector->setEvents($this->stopwatch->getSectionEvents($profile->getToken())); } catch (\InvalidArgumentException $e) { } try { $collector = $profile->getCollector('events'); $collector->setCalledListeners($this->getCalledListeners()); $collector->setNotCalledListeners($this->getNotCalledListeners()); } catch (\InvalidArgumentException $e) { } $this->profiler->saveProfile($profile); if ($updateChildren) { foreach ($profile->getChildren() as $child) { $this->saveInfoInProfile($child, true); } } }
protected function assertHasServiceInDIContainer(Profile $profile, $serviceName, $RequestedService = array("security.context")) { $logMessages = $profile->getCollector("dependency_injection")->getLogMessages(); $servicesDI = array(); if (null !== $logMessages) { foreach ($logMessages as $k => $message) { if (in_array($message['id'], $RequestedService)) { $servicesDI[] = $message['caller']['method']; } } } $this->assertContains($serviceName, implode(array_values($servicesDI))); }
/** * @param Profile $profile */ protected function validateCorsResponseDbCount(Profile $profile) { /** @var DoctrineDataCollector $doctrineDataCollector */ $doctrineDataCollector = $profile->getCollector('db'); $this->assertEquals(0, $doctrineDataCollector->getQueryCount()); }
/** * @param Response $response * @param Profile $profile */ protected function validateGetGamesCore(Response $response, Profile $profile) { $this->assertGetJsonCors($response); /** @var DoctrineDataCollector $doctrineDataCollector */ $doctrineDataCollector = $profile->getCollector('db'); // SELECT user1, SELECT game, [... SELECT user (available game)] $this->assertGreaterThanOrEqual(2, $doctrineDataCollector->getQueryCount()); }