Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Jan 19, 2016
1 parent bd66831 commit 787cf83
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions tests/PerformanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class PerformanceTest extends PHPUnit_Framework_TestCase
);

protected static $start;
protected static $message;

public static function setUpBeforeClass()
{
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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);
}
}

0 comments on commit 787cf83

Please sign in to comment.