Skip to content

Commit 5eed414

Browse files
committed
Adapt cache bench to Class_ node of AddDoesNotPerformAssertionToNonAssertingTestRector
1 parent 9871fe8 commit 5eed414

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎bench/does_not_perform_assertion_cache_bench.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Run on both branches to compare. CPU (user+sys) is the reliable metric; wall is noisy.
1212
*/
1313

14-
use PhpParser\Node\Stmt\ClassMethod;
14+
use PhpParser\Node\Stmt\Class_;
1515
use Rector\DependencyInjection\LazyContainerFactory;
1616
use Rector\PhpParser\Node\BetterNodeFinder;
1717
use Rector\PHPUnit\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector;
@@ -93,10 +93,10 @@
9393
$rector = $rectorConfig->make(AddDoesNotPerformAssertionToNonAssertingTestRector::class);
9494

9595
// parse test files up front, parent files are left for the rule to resolve
96-
$classMethods = [];
96+
$classes = [];
9797
foreach ($testFilePaths as $testFilePath) {
9898
$stmts = $testingParser->parseFileToDecoratedNodes($testFilePath);
99-
$classMethods = [...$classMethods, ...$betterNodeFinder->findInstanceOf($stmts, ClassMethod::class)];
99+
$classes = [...$classes, ...$betterNodeFinder->findInstanceOf($stmts, Class_::class)];
100100
}
101101

102102
$cpuSeconds = static function (): float {
@@ -109,8 +109,8 @@
109109
$cpuStart = $cpuSeconds();
110110

111111
$changedCount = 0;
112-
foreach ($classMethods as $classMethod) {
113-
if ($rector->refactor($classMethod) instanceof ClassMethod) {
112+
foreach ($classes as $class) {
113+
if ($rector->refactor($class) instanceof Class_) {
114114
++$changedCount;
115115
}
116116
}
@@ -121,8 +121,8 @@
121121
array_map('unlink', glob($directory . '/*.php'));
122122
@rmdir($directory);
123123

124-
printf('test classes: %d, test methods: %d, changed: %d%s', count($testFilePaths), count($classMethods), $changedCount, PHP_EOL);
125-
printf('CPU: %.4f s (%.3f ms/method)%s', $cpu, $cpu / count($classMethods) * 1000, PHP_EOL);
124+
printf('test classes: %d, changed: %d%s', count($classes), $changedCount, PHP_EOL);
125+
printf('CPU: %.4f s (%.3f ms/class)%s', $cpu, $cpu / count($classes) * 1000, PHP_EOL);
126126
printf('wall: %.4f s%s', $wall, PHP_EOL);
127127

128128
if ($cpu > MAX_CPU_SECONDS) {

0 commit comments

Comments
 (0)