From cf61cba649e3e4631d5321b65017e3b778184b24 Mon Sep 17 00:00:00 2001 From: Valentin Udaltsov Date: Fri, 9 Feb 2024 23:36:26 +0300 Subject: [PATCH] Improved MemoryLeakTest --- tests/memory/MemoryLeakTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/memory/MemoryLeakTest.php b/tests/memory/MemoryLeakTest.php index 971d0d3..5378645 100644 --- a/tests/memory/MemoryLeakTest.php +++ b/tests/memory/MemoryLeakTest.php @@ -64,6 +64,10 @@ private static function assertMemoryIsConstant(\Closure $action): void public function testTyphoonReflectorClassExistsIsNotLeaking(): void { + // warm up + TyphoonReflector::build(phpParser: self::$phpParser)->classExists(Type\NamedObjectType::class); + self::cleanUpParser(); + foreach (self::CLASSES as $class) { self::assertMemoryIsConstant(static function () use ($class): void { TyphoonReflector::build(phpParser: self::$phpParser)->classExists($class); @@ -86,6 +90,7 @@ public function testTyphoonReflectorReflectIsNotLeaking(): void public function testReflectionSessionClassExistsIsNotLeaking(): void { + // warm up $session = TyphoonReflector::build(phpParser: self::$phpParser)->startSession(); $session->classExists(Type\NamedObjectType::class); $session->flush(); @@ -101,6 +106,7 @@ public function testReflectionSessionClassExistsIsNotLeaking(): void public function testReflectionSessionReflectIsNotLeaking(): void { + // warm up $session = TyphoonReflector::build(phpParser: self::$phpParser)->startSession(); $session->reflectClass(Type\NamedObjectType::class); $session->flush();