Browse files

MDL-38698 filter_urltolink: Remove performance test in Unit Test

  • Loading branch information...
1 parent 3d94761 commit 8187097dc0295154dcb9b7805d24619991868962 @FMCorz FMCorz committed Dec 17, 2013
Showing with 0 additions and 39 deletions.
  1. +0 −39 filter/urltolink/tests/filter_test.php
View
39 filter/urltolink/tests/filter_test.php
@@ -31,19 +31,6 @@
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 @@ function test_convert_urls_into_links($text, $correctresult) {
$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)');
- }
}

0 comments on commit 8187097

Please sign in to comment.