MediaWiki  1.30.0
ProfilerSectionOnly.php
Go to the documentation of this file.
1 <?php
35  protected $sprofiler;
36 
37  public function __construct( array $params = [] ) {
38  parent::__construct( $params );
39  $this->sprofiler = new SectionProfiler();
40  }
41 
42  public function scopedProfileIn( $section ) {
43  return $this->sprofiler->scopedProfileIn( $section );
44  }
45 
46  public function close() {
47  }
48 
49  public function getFunctionStats() {
50  return $this->sprofiler->getFunctionStats();
51  }
52 
53  public function getOutput() {
54  return $this->getFunctionReport();
55  }
56 
73  protected function getFunctionReport() {
74  $data = $this->getFunctionStats();
75  usort( $data, function ( $a, $b ) {
76  if ( $a['real'] === $b['real'] ) {
77  return 0;
78  }
79  return ( $a['real'] > $b['real'] ) ? -1 : 1; // descending
80  } );
81 
82  $width = 140;
83  $nameWidth = $width - 65;
84  $format = "%-{$nameWidth}s %6d %9d %9d %9d %9d %7.3f%% %9d";
85  $out = [];
86  $out[] = sprintf( "%-{$nameWidth}s %6s %9s %9s %9s %9s %7s %9s",
87  'Name', 'Calls', 'Total', 'Min', 'Each', 'Max', '%', 'Mem'
88  );
89  foreach ( $data as $stats ) {
90  $out[] = sprintf( $format,
91  $stats['name'],
92  $stats['calls'],
93  $stats['real'] * 1000,
94  $stats['min_real'] * 1000,
95  $stats['real'] / $stats['calls'] * 1000,
96  $stats['max_real'] * 1000,
97  $stats['%real'],
98  $stats['memory']
99  );
100  }
101  return implode( "\n", $out );
102  }
103 }
ProfilerSectionOnly
Profiler that only tracks explicit profiling sections.
Definition: ProfilerSectionOnly.php:33
ProfilerSectionOnly\getFunctionReport
getFunctionReport()
Get a report of profiled functions sorted by inclusive wall clock time in descending order.
Definition: ProfilerSectionOnly.php:73
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Profiler
Profiler base class that defines the interface and some trivial functionality.
Definition: Profiler.php:33
SectionProfiler
Custom PHP profiler for parser/DB type section names that xhprof/xdebug can't handle.
Definition: SectionProfiler.php:30
ProfilerSectionOnly\getFunctionStats
getFunctionStats()
Get the aggregated inclusive profiling data for each method.
Definition: ProfilerSectionOnly.php:49
ProfilerSectionOnly\scopedProfileIn
scopedProfileIn( $section)
Mark the start of a custom profiling frame (e.g.
Definition: ProfilerSectionOnly.php:42
ProfilerSectionOnly\close
close()
Close opened profiling sections.
Definition: ProfilerSectionOnly.php:46
ProfilerSectionOnly\getOutput
getOutput()
Returns a profiling output to be stored in debug file.
Definition: ProfilerSectionOnly.php:53
$section
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
Definition: hooks.txt:2981
ProfilerSectionOnly\__construct
__construct(array $params=[])
Definition: ProfilerSectionOnly.php:37
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Profiler\$params
array $params
All of the params passed from $wgProfiler.
Definition: Profiler.php:39
array
the array() calling protocol came about after MediaWiki 1.4rc1.
ProfilerSectionOnly\$sprofiler
SectionProfiler $sprofiler
Definition: ProfilerSectionOnly.php:35
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:781