Merge "Use milliseconds for time profiling"

This commit is contained in:
jenkins-bot 2019-08-04 16:12:59 +00:00 committed by Gerrit Code Review
commit c0b6267022
3 changed files with 12 additions and 17 deletions

View file

@ -594,15 +594,11 @@ class AbuseFilter {
return [ 0, 0, 0, 0 ];
}
// 1000 ms in a sec
$timeProfile = ( $curTotalTime / $curCount ) * 1000;
// Return in ms, rounded to 2dp
$timeProfile = round( $timeProfile, 2 );
// Return in milliseconds, rounded to 2dp
$avgTime = round( $curTotalTime / $curCount, 2 );
$avgCond = round( $curTotalConds / $curCount, 1 );
$condProfile = ( $curTotalConds / $curCount );
$condProfile = round( $condProfile, 0 );
return [ $curCount, $profile['matches'], $timeProfile, $condProfile ];
return [ $curCount, $profile['matches'], $avgTime, $avgCond ];
}
/**
@ -1014,7 +1010,7 @@ class AbuseFilter {
*/
public static function filterProfileKey( $filter ) {
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
return $cache->makeKey( 'abusefilter-profile', 'v2', $filter );
return $cache->makeKey( 'abusefilter-profile', 'v3', $filter );
}
/**

View file

@ -375,7 +375,7 @@ class AbuseFilterRunner {
$pattern = trim( $row->af_pattern );
$result = AbuseFilter::checkConditions( $pattern, $this->parser, true, $filterName );
$timeTaken = microtime( true ) - $startTime;
$timeTaken = 1000 * ( microtime( true ) - $startTime );
$condsUsed = $this->parser->getCondCount() - $startConds;
$this->profilingData[$filterName] = [
@ -403,9 +403,8 @@ class AbuseFilterRunner {
$this->recordProfilingResult( $filterID, $params['time'], $params['conds'], $params['result'] );
}
$runtime = $params['time'] * 1000;
if ( $runtime > $wgAbuseFilterSlowFilterRuntimeLimit ) {
$this->recordSlowFilter( $filterName, $runtime, $params['conds'], $params['result'] );
if ( $params['time'] > $wgAbuseFilterSlowFilterRuntimeLimit ) {
$this->recordSlowFilter( $filterName, $params['time'], $params['conds'], $params['result'] );
}
}
}
@ -414,7 +413,7 @@ class AbuseFilterRunner {
* Record per-filter profiling data
*
* @param int $filter
* @param float $time
* @param float $time Time taken, in milliseconds
* @param int $conds
* @param bool $matched
*/

View file

@ -1832,7 +1832,7 @@ class AbuseFilterConsequencesTest extends MediaWikiTestCase {
17 => [
'matches' => 1,
'actions' => 6,
'averageConditions' => 4.0
'averageConditions' => 4.3
],
19 => [
'matches' => 1,
@ -1872,7 +1872,7 @@ class AbuseFilterConsequencesTest extends MediaWikiTestCase {
17 => [
'matches' => 1,
'actions' => 6,
'averageConditions' => 4.0
'averageConditions' => 4.3
],
19 => [
'matches' => 1,
@ -1912,7 +1912,7 @@ class AbuseFilterConsequencesTest extends MediaWikiTestCase {
17 => [
'matches' => 1,
'actions' => 6,
'averageConditions' => 4.0
'averageConditions' => 4.3
],
19 => [
'matches' => 1,