PHP Twig_Profiler_Profile Code Examples

This page contains top rated real world PHP examples of Twig_Profiler_Profile extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: AbstractTest.php Project: tahermarkos/Transport
0
 protected function getProfile()
 {
     $profile = new Twig_Profiler_Profile();
     $index = new Twig_Profiler_Profile('index.twig', Twig_Profiler_Profile::TEMPLATE);
     $profile->addProfile($index);
     $body = new Twig_Profiler_Profile('embedded.twig', Twig_Profiler_Profile::BLOCK, 'body');
     $body->leave();
     $index->addProfile($body);
     $embedded = new Twig_Profiler_Profile('embedded.twig', Twig_Profiler_Profile::TEMPLATE);
     $included = new Twig_Profiler_Profile('included.twig', Twig_Profiler_Profile::TEMPLATE);
     $embedded->addProfile($included);
     $index->addProfile($embedded);
     $included->leave();
     $embedded->leave();
     $macro = new Twig_Profiler_Profile('index.twig', Twig_Profiler_Profile::MACRO, 'foo');
     $macro->leave();
     $index->addProfile($macro);
     $embedded = clone $embedded;
     $index->addProfile($embedded);
     $a = range(1, 1000);
     $embedded->leave();
     $profile->leave();
     usleep(5000);
     $index->leave();
     return $profile;
 }
Example #2
Show file File: ProfilerExtension.php Project: Ener-Getick/symfony
0
 public function enter(\Twig_Profiler_Profile $profile)
 {
     if ($this->stopwatch && $profile->isTemplate()) {
         $this->events[$profile] = $this->stopwatch->start($profile->getName(), 'template');
     }
     parent::enter($profile);
 }
Example #3
Show file File: Profiler.php Project: Dren-x/mobit
0
 public function leave(Twig_Profiler_Profile $profile)
 {
     $profile->leave();
     array_shift($this->actives);
     if (1 === count($this->actives)) {
         $this->actives[0]->leave();
     }
 }
Example #4
Show file File: TwigArrayDumper.php Project: kletellier/mvc
0
 private function format(\Twig_Profiler_Profile $profile)
 {
     $tmp = array();
     $tmp["template"] = $profile->getTemplate();
     $tmp["name"] = $profile->getName();
     $tmp["duration"] = $profile->getDuration();
     $tmp["type"] = $profile->getType();
     return $tmp;
 }
Example #5
Show file File: HandlebarsProfileExtension.php Project: jayS-de/HandlebarsBundle
0
 public function leave(\Twig_Profiler_Profile $profile)
 {
     $profile->leave();
     array_shift($this->actives);
     if (1 === count($this->actives)) {
         $this->actives[0]->leave();
     }
     if ($this->stopwatch && $profile->isTemplate()) {
         $this->events[$profile]->stop();
         unset($this->events[$profile]);
     }
 }
Example #6
Show file File: ProfileTest.php Project: tahermarkos/Transport
0
 public function testSerialize()
 {
     $profile = new Twig_Profiler_Profile('template', 'type', 'name');
     $profile1 = new Twig_Profiler_Profile('template1', 'type1', 'name1');
     $profile->addProfile($profile1);
     $profile->leave();
     $profile1->leave();
     $profile2 = unserialize(serialize($profile));
     $profiles = $profile->getProfiles();
     $this->assertCount(1, $profiles);
     $profile3 = $profiles[0];
     $this->assertEquals($profile->getTemplate(), $profile2->getTemplate());
     $this->assertEquals($profile->getType(), $profile2->getType());
     $this->assertEquals($profile->getName(), $profile2->getName());
     $this->assertEquals($profile->getDuration(), $profile2->getDuration());
     $this->assertEquals($profile1->getTemplate(), $profile3->getTemplate());
     $this->assertEquals($profile1->getType(), $profile3->getType());
     $this->assertEquals($profile1->getName(), $profile3->getName());
 }
Example #7
Show file File: Text.php Project: DeDoOozZz/brighterycms
0
 private function dumpProfile(Twig_Profiler_Profile $profile, $prefix = '', $sibling = false)
 {
     if ($profile->isRoot()) {
         $this->root = $profile->getDuration();
         $start = $profile->getName();
     } else {
         if ($profile->isTemplate()) {
             $start = $this->formatTemplate($profile, $prefix);
         } else {
             $start = $this->formatNonTemplate($profile, $prefix);
         }
         $prefix .= $sibling ? '│ ' : '  ';
     }
     $percent = $this->root ? $profile->getDuration() / $this->root * 100 : 0;
     if ($profile->getDuration() * 1000 < 1) {
         $str = $start . "\n";
     } else {
         $str = sprintf("%s %s\n", $start, $this->formatTime($profile, $percent));
     }
     $nCount = count($profile->getProfiles());
     foreach ($profile as $i => $p) {
         $str .= $this->dumpProfile($p, $prefix, $i + 1 !== $nCount);
     }
     return $str;
 }
Example #8
Show file File: Blackfire.php Project: TheTypoMaster/SPHERE-Framework
0
 private function dumpProfile($edge, Twig_Profiler_Profile $profile, &$data)
 {
     if (isset($data[$edge])) {
         $data[$edge]['ct'] += 1;
         $data[$edge]['wt'] += floor($profile->getDuration() * 1000000);
         $data[$edge]['mu'] += $profile->getMemoryUsage();
         $data[$edge]['pmu'] += $profile->getPeakMemoryUsage();
     } else {
         $data[$edge] = array('ct' => 1, 'wt' => floor($profile->getDuration() * 1000000), 'mu' => $profile->getMemoryUsage(), 'pmu' => $profile->getPeakMemoryUsage());
     }
 }
Example #9
Show file File: Html.php Project: pablodalloglio/phpoo
0
 protected function formatTime(Twig_Profiler_Profile $profile, $percent)
 {
     return sprintf('<span style="color: %s">%.2fms/%.0f%%</span>', $percent > 20 ? self::$colors['big'] : 'auto', $profile->getDuration() * 1000, $percent);
 }
Example #10
Show file File: Text.php Project: betes-curieuses-design/ElieJosiePhotographie
0
 protected function formatTime(Twig_Profiler_Profile $profile, $percent)
 {
     return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent);
 }
Example #11
Show file File: Profiler.php Project: luisfredgs/TwigView
0
 /**
  * Enter $profile.
  *
  * @param \Twig_Profiler_Profile $profile Profile.
  *
  * @return void
  */
 public function enter(\Twig_Profiler_Profile $profile)
 {
     $name = 'Twig Template: ' . substr($profile->getName(), strlen(ROOT) + 1);
     DebugTimer::start($name, __d('twig_view', $name));
     parent::enter($profile);
 }
Example #12
Show file File: HandlebarsDataCollectorTest.php Project: jayS-de/HandlebarsBundle
0
 public function testHtmlGraph()
 {
     $profile = new \Twig_Profiler_Profile();
     $template1 = new \Twig_Profiler_Profile('template1', \Twig_Profiler_Profile::TEMPLATE, 'template1');
     $profile->addProfile($template1);
     $profile->enter();
     $template1->enter();
     usleep(10000);
     $template1->leave();
     $profile->leave();
     $collector = new HandlebarsDataCollector($profile);
     $this->assertContains('template1', (string) $collector->getHtmlCallGraph());
 }
Example #13
Show file File: HandlebarsDataCollector.php Project: jayS-de/HandlebarsBundle
0
 protected function incTemplateCount(\Twig_Profiler_Profile $p, $templates)
 {
     if ($p->isTemplate()) {
         if (!isset($templates[$p->getTemplate()])) {
             $templates[$p->getTemplate()] = 1;
         } else {
             ++$templates[$p->getTemplate()];
         }
     }
     return $templates;
 }