From 787cf837192ac8bd97386200fc66d513c0de7657 Mon Sep 17 00:00:00 2001 From: overtrue Date: Tue, 19 Jan 2016 14:57:04 +0800 Subject: [PATCH] Fix tests. --- tests/PerformanceTest.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/PerformanceTest.php b/tests/PerformanceTest.php index 60512678..2dd6c59c 100644 --- a/tests/PerformanceTest.php +++ b/tests/PerformanceTest.php @@ -32,6 +32,7 @@ class PerformanceTest extends PHPUnit_Framework_TestCase ); protected static $start; + protected static $message; public static function setUpBeforeClass() { @@ -40,12 +41,7 @@ public static function setUpBeforeClass() public static function tearDownAfterClass() { - echo "Total timeusage(5000 items): ",microtime(true) - static::$start,"\n"; - } - - public function setUp() - { - echo "\n****************\n"; + echo self::$message . "\nTotal timeusage: ", microtime(true) - static::$start,"\n"; } public function testSingleChars() @@ -56,7 +52,7 @@ public function testSingleChars() Pinyin::trans($line); } - echo "\nSingle chars time usage:". (microtime(true) - $timestart), "\n"; + self::$message .= "\nSingle chars time usage: ". (microtime(true) - $timestart); } public function testDictionary() @@ -65,10 +61,10 @@ public function testDictionary() $dictionary = json_decode(file_get_contents(__DIR__ .'/../src/data/dict.php'), true); $items = array_keys($dictionary); - foreach (array_slice($items, 20, 5000) as $line) { + foreach (array_slice($items, 20, 50000) as $line) { Pinyin::trans($line); } - echo "\nDictionary chars time usage:". (microtime(true) - $timestart), "\n"; + self::$message .= "\nDictionary chars time usage: ". (microtime(true) - $timestart); } } \ No newline at end of file