29 use MediaWikiCoversValidator;
41 [
'main()', [
null,
'main()' ] ],
42 [
'foo==>bar', [
'foo',
'bar' ] ],
43 [
'bar@1==>bar@2', [
'bar@1',
'bar@2' ] ],
44 [
'foo==>bar==>baz', [
'foo',
'bar==>baz' ] ],
45 [
'==>bar', [
'',
'bar' ] ],
55 'include' => [
'main()' ],
57 $raw = $xhprofData->getRawData();
58 $this->assertArrayHasKey(
'main()', $raw );
59 $this->assertArrayHasKey(
'main()==>foo', $raw );
60 $this->assertArrayHasKey(
'main()==>xhprof_disable', $raw );
61 $this->assertSame( 3, count( $raw ) );
85 'variance' =>
'numeric',
86 'percent' =>
'numeric',
90 $metrics = $xhprofData->getInclusiveMetrics();
92 foreach ( $metrics as $name => $metric ) {
95 foreach ( $metricStruct as $key =>
$type ) {
96 if (
$type ===
'array' ) {
98 if ( $name ===
'main()' ) {
99 $this->assertEquals( 100, $metric[$key][
'percent'] );
122 'subcalls' =>
'array',
124 $statsMetrics = [
'wt',
'cpu',
'mu',
'pmu' ];
126 'total' =>
'numeric',
130 'variance' =>
'numeric',
131 'percent' =>
'numeric',
132 'exclusive' =>
'numeric',
136 $metrics = $xhprofData->getCompleteMetrics();
138 foreach ( $metrics as $name => $metric ) {
141 foreach ( $metricStruct as $key =>
$type ) {
142 if ( in_array( $key, $statsMetrics ) ) {
144 $statStruct, $metric[$key], $key
146 $this->assertLessThanOrEqual(
147 $metric[$key][
'total'], $metric[$key][
'exclusive']
161 $this->assertSame( [], $xhprofData->getCallers(
'main()' ) );
162 $this->assertSame( [
'foo',
'xhprof_disable' ],
163 $xhprofData->getCallees(
'main()' )
165 $this->assertSame( [
'main()' ],
166 $xhprofData->getCallers(
'foo' )
168 $this->assertSame( [], $xhprofData->getCallees(
'strlen' ) );
177 $path = $xhprofData->getCriticalPath();
180 foreach ( $path as $key =>
$value ) {
182 $this->assertSame(
$last, $func );
185 $this->assertSame(
$last,
'bar@1' );
246 'main()==>xhprof_disable' => [
271 $this->assertInternalType(
'array', $actual, $label );
272 $this->assertCount( count( $struct ), $actual, $label );
273 foreach ( $struct as $key =>
$type ) {
274 $this->assertArrayHasKey( $key, $actual );
275 $this->assertInternalType(
$type, $actual[$key] );
@uses XhprofData @uses AutoLoader
testEdges()
XhprofData::getCallers XhprofData::getCallees @uses XhprofData.
getXhprofDataFixture(array $opts=[])
Get an Xhprof instance that has been primed with a set of known testing data.
testCriticalPath()
XhprofData::getCriticalPath @uses XhprofData.
testSplitKey( $key, $expect)
XhprofData::splitKey provideSplitKey.
testInclude()
XhprofData::pruneData.
assertArrayStructure( $struct, $actual, $label=null)
Assert that the given array has the described structure.
testInclusiveMetricsStructure()
Validate the structure of data returned by Xhprof::getInclusiveMetrics().
testCompleteMetricsStructure()
Validate the structure of data returned by Xhprof::getCompleteMetrics().
Convenience class for working with XHProf profiling data https://github.com/phacility/xhprof.
static splitKey( $key)
Convert an xhprof data key into an array of ['parent', 'child'] function names.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list