mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 21:53:35 +00:00
Use milliseconds for time profiling
Instead of seconds, and round the average condition at 1dp instead of 0. Split from child patch by Dragons flight. Depends-On: I2d8c8f8278073a9420e3eb373fb89a655925618a Change-Id: I339aed5f8c1d49714e7927ce49286f9ce6c839f5
This commit is contained in:
parent
0b7902fe6e
commit
c3db63714e
|
@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue