mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-27 23:40:19 +00:00
Merge "Use milliseconds for time profiling"
This commit is contained in:
commit
c0b6267022
|
@ -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