X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fprofiler%2FSectionProfiler.php;h=92e276d7660f0f1891cc1f882493c5ce69164bc8;hp=b00401d9bf788920344181ab2119fd6098095a00;hb=9e8439e79d67788916d488f645108f79016d9aca;hpb=982d2c6e627eac726d82fa4bc7776085b87a0dbb diff --git a/includes/profiler/SectionProfiler.php b/includes/profiler/SectionProfiler.php index b00401d9bf..92e276d766 100644 --- a/includes/profiler/SectionProfiler.php +++ b/includes/profiler/SectionProfiler.php @@ -96,9 +96,15 @@ class SectionProfiler { public function getFunctionStats() { $this->collateData(); - $totalCpu = max( $this->end['cpu'] - $this->start['cpu'], 0 ); - $totalReal = max( $this->end['real'] - $this->start['real'], 0 ); - $totalMem = max( $this->end['memory'] - $this->start['memory'], 0 ); + if ( is_array( $this->start ) ) { + $totalCpu = max( $this->end['cpu'] - $this->start['cpu'], 0 ); + $totalReal = max( $this->end['real'] - $this->start['real'], 0 ); + $totalMem = max( $this->end['memory'] - $this->start['memory'], 0 ); + } else { + $totalCpu = 0; + $totalReal = 0; + $totalMem = 0; + } $profile = []; foreach ( $this->collated as $fname => $data ) { @@ -496,29 +502,3 @@ class SectionProfiler { } } } - -/** - * Subclass ScopedCallback to avoid call_user_func_array(), which is slow - * - * This class should not be used outside of SectionProfiler - */ -class SectionProfileCallback extends ScopedCallback { - /** @var SectionProfiler */ - protected $profiler; - /** @var string */ - protected $section; - - /** - * @param SectionProfiler $profiler - * @param string $section - */ - public function __construct( SectionProfiler $profiler, $section ) { - parent::__construct( null ); - $this->profiler = $profiler; - $this->section = $section; - } - - function __destruct() { - $this->profiler->profileOutInternal( $this->section ); - } -}