MDL-38698 filter_urltolink: Remove performance test in Unit Test
This commit is contained in:
@@ -31,19 +31,6 @@ require_once($CFG->dirroot . '/filter/urltolink/filter.php'); // Include the cod
|
||||
|
||||
class filter_urltolink_testcase extends basic_testcase {
|
||||
|
||||
/**
|
||||
* Helper function that represents the legacy implementation
|
||||
* of convert_urls_into_links()
|
||||
*/
|
||||
protected function old_convert_urls_into_links(&$text) {
|
||||
/// Make lone URLs into links. eg http://moodle.com/
|
||||
$text = preg_replace("%([[:space:]]|^|\(|\[)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])%i",
|
||||
'$1<a href="$2://$3$4" target="_blank">$2://$3$4</a>', $text);
|
||||
/// eg www.moodle.com
|
||||
$text = preg_replace("%([[:space:]]|^|\(|\[)www\.([^[:space:]]*)([[:alnum:]#?/&=])%i",
|
||||
'$1<a href="http://www.$2$3" target="_blank">www.$2$3</a>', $text);
|
||||
}
|
||||
|
||||
function get_convert_urls_into_links_test_cases() {
|
||||
$texts = array (
|
||||
//just a url
|
||||
@@ -186,32 +173,6 @@ class filter_urltolink_testcase extends basic_testcase {
|
||||
$this->assertEquals($correctresult, $text);
|
||||
}
|
||||
|
||||
function test_convert_urls_into_links_performance() {
|
||||
$testablefilter = new testable_filter_urltolink();
|
||||
|
||||
$reps = 1000;
|
||||
$text = file_get_contents(__DIR__ . '/fixtures/sample.txt');
|
||||
$time_start = microtime(true);
|
||||
for($i=0;$i<$reps;$i++) {
|
||||
$testablefilter->convert_urls_into_links($text);
|
||||
}
|
||||
$time_end = microtime(true);
|
||||
$new_time = $time_end - $time_start;
|
||||
|
||||
$time_start = microtime(true);
|
||||
for($i=0;$i<$reps;$i++) {
|
||||
$this->old_convert_urls_into_links($text);
|
||||
}
|
||||
$time_end = microtime(true);
|
||||
$old_time = $time_end - $time_start;
|
||||
|
||||
$fast_enough = false;
|
||||
if( $new_time < $old_time ) {
|
||||
$fast_enough = true;
|
||||
}
|
||||
|
||||
$this->assertEquals($fast_enough, true, 'Timing test: ' . $new_time . 'secs (new) < ' . $old_time . 'secs (old)');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user