jenkins-bot has submitted this change and it was merged.
Change subject: Refactored xhprof getFunctionReport() to use getFunctionStats()
......................................................................
Refactored xhprof getFunctionReport() to use getFunctionStats()
* Also added more doc comments to getFunctionStats()
Change-Id: I3741713d3c80b0bbc622eb17ce4c3a047bf5a06c
---
M includes/profiler/Profiler.php
M includes/profiler/ProfilerStandard.php
M includes/profiler/ProfilerXhprof.php
3 files changed, 30 insertions(+), 23 deletions(-)
Approvals:
BryanDavis: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/profiler/Profiler.php b/includes/profiler/Profiler.php
index 2be142f..667a9e2 100644
--- a/includes/profiler/Profiler.php
+++ b/includes/profiler/Profiler.php
@@ -241,14 +241,16 @@
* This makes filtering them out easier and follows the xhprof style.
*
* @return array List of method entries arrays, each having:
- * - name : method name
- * - calls : the number of invoking calls
- * - real : real time ellapsed (ms)
- * - %real : percent real time
- * - cpu : CPU time ellapsed (ms)
- * - %cpu : percent CPU time
- * - memory : memory used (bytes)
- * - %memory : percent memory used
+ * - name : method name
+ * - calls : the number of invoking calls
+ * - real : real time ellapsed (ms)
+ * - %real : percent real time
+ * - cpu : CPU time ellapsed (ms)
+ * - %cpu : percent CPU time
+ * - memory : memory used (bytes)
+ * - %memory : percent memory used
+ * - min_real : min real time in a call (ms)
+ * - max_real : max real time in a call (ms)
* @since 1.25
*/
abstract public function getFunctionStats();
diff --git a/includes/profiler/ProfilerStandard.php
b/includes/profiler/ProfilerStandard.php
index ffcd7d9..b40519e 100644
--- a/includes/profiler/ProfilerStandard.php
+++ b/includes/profiler/ProfilerStandard.php
@@ -485,8 +485,8 @@
'%cpu' => $totalCpu ? 100 * $data['cpu'] /
$totalCpu : 0,
'memory' => $data['memory'],
'%memory' => $totalMem ? 100 * $data['memory']
/ $totalMem : 0,
- 'min' => $data['min_real'] * 1000,
- 'max' => $data['max_real'] * 1000
+ 'min_real' => $data['min_real'] * 1000,
+ 'max_real' => $data['max_real'] * 1000
);
}
diff --git a/includes/profiler/ProfilerXhprof.php
b/includes/profiler/ProfilerXhprof.php
index d3d4cf1..2fef011 100644
--- a/includes/profiler/ProfilerXhprof.php
+++ b/includes/profiler/ProfilerXhprof.php
@@ -157,8 +157,8 @@
'%cpu' => isset( $stats['cpu'] ) ?
$stats['cpu']['percent'] : 0,
'memory' => isset( $stats['mu'] ) ?
$stats['mu']['total'] : 0,
'%memory' => isset( $stats['mu'] ) ?
$stats['mu']['percent'] : 0,
- 'min' => $stats['wt']['min'] / 1000,
- 'max' => $stats['wt']['max'] / 1000
+ 'min_real' => $stats['wt']['min'] / 1000,
+ 'max_real' => $stats['wt']['max'] / 1000
);
}
@@ -191,8 +191,13 @@
* @return string
*/
protected function getFunctionReport() {
- $data = $this->xhprof->getInclusiveMetrics();
- uasort( $data, Xhprof::makeSortFunction( 'wt', 'total' ) );
+ $data = $this->getFunctionStats();
+ usort( $data, function( $a, $b ) {
+ if ( $a['real'] === $b['real'] ) {
+ return 0;
+ }
+ return ( $a['real'] > $b['real'] ) ? -1 : 1; //
descending
+ } );
$width = 140;
$nameWidth = $width - 65;
@@ -201,16 +206,16 @@
$out[] = sprintf( "%-{$nameWidth}s %6s %9s %9s %9s %9s %7s %9s",
'Name', 'Calls', 'Total', 'Min', 'Each', 'Max', '%',
'Mem'
);
- foreach ( $data as $func => $stats ) {
+ foreach ( $data as $stats ) {
$out[] = sprintf( $format,
- $func,
- $stats['ct'],
- $stats['wt']['total'],
- $stats['wt']['min'],
- $stats['wt']['mean'],
- $stats['wt']['max'],
- $stats['wt']['percent'],
- isset( $stats['mu'] ) ? $stats['mu']['total'] : 0
+ $stats['name'],
+ $stats['calls'],
+ $stats['real'] * 1000,
+ $stats['min_real'] * 1000,
+ $stats['real'] / $stats['calls'] * 1000,
+ $stats['max_real'] * 1000,
+ $stats['%real'],
+ $stats['memory']
);
}
return implode( "\n", $out );
--
To view, visit https://gerrit.wikimedia.org/r/178292
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3741713d3c80b0bbc622eb17ce4c3a047bf5a06c
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits