Code Duplication    Length = 30-30 lines in 2 locations

includes/profiler/ProfilerSectionOnly.php 1 location

@@ 74-103 (lines=30) @@
71
	 *
72
	 * @return string
73
	 */
74
	protected function getFunctionReport() {
75
		$data = $this->getFunctionStats();
76
		usort( $data, function( $a, $b ) {
77
			if ( $a['real'] === $b['real'] ) {
78
				return 0;
79
			}
80
			return ( $a['real'] > $b['real'] ) ? -1 : 1; // descending
81
		} );
82
83
		$width = 140;
84
		$nameWidth = $width - 65;
85
		$format = "%-{$nameWidth}s %6d %9d %9d %9d %9d %7.3f%% %9d";
86
		$out = [];
87
		$out[] = sprintf( "%-{$nameWidth}s %6s %9s %9s %9s %9s %7s %9s",
88
			'Name', 'Calls', 'Total', 'Min', 'Each', 'Max', '%', 'Mem'
89
		);
90
		foreach ( $data as $stats ) {
91
			$out[] = sprintf( $format,
92
				$stats['name'],
93
				$stats['calls'],
94
				$stats['real'] * 1000,
95
				$stats['min_real'] * 1000,
96
				$stats['real'] / $stats['calls'] * 1000,
97
				$stats['max_real'] * 1000,
98
				$stats['%real'],
99
				$stats['memory']
100
			);
101
		}
102
		return implode( "\n", $out );
103
	}
104
}
105

includes/profiler/ProfilerXhprof.php 1 location

@@ 197-226 (lines=30) @@
194
	 *
195
	 * @return string
196
	 */
197
	protected function getFunctionReport() {
198
		$data = $this->getFunctionStats();
199
		usort( $data, function( $a, $b ) {
200
			if ( $a['real'] === $b['real'] ) {
201
				return 0;
202
			}
203
			return ( $a['real'] > $b['real'] ) ? -1 : 1; // descending
204
		} );
205
206
		$width = 140;
207
		$nameWidth = $width - 65;
208
		$format = "%-{$nameWidth}s %6d %9d %9d %9d %9d %7.3f%% %9d";
209
		$out = [];
210
		$out[] = sprintf( "%-{$nameWidth}s %6s %9s %9s %9s %9s %7s %9s",
211
			'Name', 'Calls', 'Total', 'Min', 'Each', 'Max', '%', 'Mem'
212
		);
213
		foreach ( $data as $stats ) {
214
			$out[] = sprintf( $format,
215
				$stats['name'],
216
				$stats['calls'],
217
				$stats['real'] * 1000,
218
				$stats['min_real'] * 1000,
219
				$stats['real'] / $stats['calls'] * 1000,
220
				$stats['max_real'] * 1000,
221
				$stats['%real'],
222
				$stats['memory']
223
			);
224
		}
225
		return implode( "\n", $out );
226
	}
227
228
	/**
229
	 * Retrieve raw data from xhprof