Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php |
— | — | @@ -270,13 +270,17 @@ |
271 | 271 | |
272 | 272 | if ($total > 0) { |
273 | 273 | $matches_percent = sprintf( '%.2f', 100 * $matches_count / $total ); |
274 | | - $profile = AbuseFilter::getFilterProfile( $filter ); |
| 274 | + list($timeProfile, $condProfile) = AbuseFilter::getFilterProfile( $filter ); |
| 275 | + |
275 | 276 | $fields['abusefilter-edit-status-label'] = |
276 | 277 | wfMsgExt( 'abusefilter-edit-status', array( 'parsemag', 'escape' ), |
277 | | - $wgLang->formatNum($total), |
278 | | - $wgLang->formatNum($matches_count), |
279 | | - $wgLang->formatNum($matches_percent), |
280 | | - $wgLang->formatNum($profile) |
| 278 | + array( |
| 279 | + $wgLang->formatNum($total), |
| 280 | + $wgLang->formatNum($matches_count), |
| 281 | + $wgLang->formatNum($matches_percent), |
| 282 | + $wgLang->formatNum($timeProfile), |
| 283 | + $wgLang->formatNum($condProfile) |
| 284 | + ) |
281 | 285 | ); |
282 | 286 | } |
283 | 287 | } |
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php |
— | — | @@ -423,8 +423,10 @@ |
424 | 424 | public static function checkFilter( $row, $vars, $profile = false, $prefix = '' ) { |
425 | 425 | $filterID = $prefix.$row->af_id; |
426 | 426 | |
427 | | - if ($profile) |
| 427 | + if ($profile) { |
| 428 | + $startConds = self::$condCount; |
428 | 429 | $startTime = microtime(true); |
| 430 | + } |
429 | 431 | |
430 | 432 | // Store the row somewhere convenient |
431 | 433 | self::$filters[$filterID] = $row; |
— | — | @@ -442,10 +444,12 @@ |
443 | 445 | |
444 | 446 | if ($profile) { |
445 | 447 | $endTime = microtime(true); |
| 448 | + $endConds = self::$condCount; |
446 | 449 | |
447 | 450 | $timeTaken = $endTime - $startTime; |
| 451 | + $condsUsed = $endConds - $startConds; |
448 | 452 | |
449 | | - self::recordProfilingResult( $row->af_id, $timeTaken ); |
| 453 | + self::recordProfilingResult( $row->af_id, $timeTaken, $condsUsed ); |
450 | 454 | } |
451 | 455 | |
452 | 456 | return $result; |
— | — | @@ -460,21 +464,25 @@ |
461 | 465 | $wgMemc->delete( $totalKey ); |
462 | 466 | } |
463 | 467 | |
464 | | - public static function recordProfilingResult( $filter, $time ) { |
| 468 | + public static function recordProfilingResult( $filter, $time, $conds ) { |
465 | 469 | global $wgMemc; |
466 | 470 | |
467 | 471 | $countKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'count' ); |
468 | 472 | $totalKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'total' ); |
| 473 | + $totalCondKey = wfMemcKey( 'abusefilter', 'profile-conds', 'total' ); |
469 | 474 | |
470 | 475 | $curCount = $wgMemc->get( $countKey ); |
471 | 476 | $curTotal = $wgMemc->get( $totalKey ); |
| 477 | + $curTotalConds = $wgMemc->get( $totalCondKey ); |
472 | 478 | |
473 | 479 | if ($curCount) { |
| 480 | + $wgMemc->set( $totalCondKey, $curTotalConds + $conds, 3600 ); |
474 | 481 | $wgMemc->set( $totalKey, $curTotal + $time, 3600 ); |
475 | 482 | $wgMemc->incr( $countKey ); |
476 | 483 | } else { |
477 | 484 | $wgMemc->set( $countKey, 1, 3600 ); |
478 | | - $wgMemc->set( $totalKey, $time, 3600 ); |
| 485 | + $wgMemc->set( $totalKey, $time, 3600 ); |
| 486 | + $wgMemc->set( $totalCondKey, $conds, 3600 ); |
479 | 487 | } |
480 | 488 | } |
481 | 489 | |
— | — | @@ -483,15 +491,22 @@ |
484 | 492 | |
485 | 493 | $countKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'count' ); |
486 | 494 | $totalKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'total' ); |
| 495 | + $totalCondKey = wfMemcKey( 'abusefilter', 'profile-conds', 'total' ); |
487 | 496 | |
488 | 497 | $curCount = $wgMemc->get( $countKey ); |
489 | 498 | $curTotal = $wgMemc->get( $totalKey ); |
| 499 | + $curTotalConds = $wgMemc->get( $totalCondKey ); |
490 | 500 | |
491 | 501 | if (!$curCount) |
492 | | - return 0; |
| 502 | + return array( 0, 0 ); |
493 | 503 | |
494 | | - $profile = ($curTotal / $curCount) * 1000; |
495 | | - return round( $profile, 2); // Return in ms, rounded to 2dp |
| 504 | + $timeProfile = ($curTotal / $curCount) * 1000; // 1000 ms in a sec |
| 505 | + $timeProfile = round( $timeProfile, 2); // Return in ms, rounded to 2dp |
| 506 | + |
| 507 | + $condProfile = ($curTotalConds / $curCount); |
| 508 | + $condProfile = round( $condProfile, 0 ); |
| 509 | + |
| 510 | + return array( $timeProfile, $condProfile ); |
496 | 511 | } |
497 | 512 | |
498 | 513 | /** Utility function to decode global-$index to $index. Returns false if not global */ |
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php |
— | — | @@ -158,7 +158,7 @@ |
159 | 159 | [[Special:AbuseFilter/history/$2|Return to this filter's history]].", |
160 | 160 | 'abusefilter-edit-status-label' => 'Statistics:', |
161 | 161 | 'abusefilter-edit-status' => 'Of the last $1 {{PLURAL:$1|action|actions}}, this filter has matched $2 ($3%). |
162 | | -On average, its run time is $4ms', |
| 162 | +On average, its run time is $4ms, and it consumes $5 {{PLURAL:$5|condition|conditions}} of the condition limit.', |
163 | 163 | 'abusefilter-edit-throttled' => "'''Warning''': This filter was automatically disabled as a safety measure. |
164 | 164 | It reached the limit of matching more than $1% of actions.", |
165 | 165 | 'abusefilter-edit-new' => 'New filter', |