Skip to content

Commit e5bab5d

Browse files
committed
Changed Loop::run test time measurements to be taken outside the async loop.
1 parent f936cc4 commit e5bab5d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

test/Unit/AsyncExponentialBackoffExceptionHandlerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ public function test()
1515
{
1616
$handler = new AsyncExponentialBackoffExceptionHandler;
1717

18-
\Amp\Loop::run(static function () use ($handler): \Generator {
19-
$start = microtime(true);
18+
$start = microtime(true);
2019

20+
\Amp\Loop::run(static function () use ($handler): \Generator {
2121
for ($counter = 0; $counter < 4; ++$counter) {
2222
yield $handler();
2323
}
24-
25-
self::assertGreaterThan($start + 1.5, microtime(true));
2624
});
25+
26+
self::assertGreaterThan($start + 1.5, microtime(true));
2727
}
2828
}

test/Unit/AsyncMilliSleepExceptionHandlerTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ public function testValue()
1515
{
1616
$handler = new AsyncMilliSleepExceptionHandler(new \ArrayIterator([1000]));
1717

18-
\Amp\Loop::run(static function () use ($handler): \Generator {
19-
$start = microtime(true);
18+
$start = microtime(true);
2019

20+
\Amp\Loop::run(static function () use ($handler): \Generator {
2121
yield $handler();
22-
23-
self::assertGreaterThan($start + 1, microtime(true));
2422
});
23+
24+
self::assertGreaterThan($start + 1, microtime(true));
2525
}
2626

2727
public function testSeries()
@@ -30,14 +30,14 @@ public function testSeries()
3030
new \ArrayIterator($delays = array_fill(0, $limit = 10, 100))
3131
);
3232

33-
\Amp\Loop::run(static function () use ($handler, $limit): \Generator {
34-
$start = microtime(true);
33+
$start = microtime(true);
3534

35+
\Amp\Loop::run(static function () use ($handler, $limit): \Generator {
3636
for ($counter = 0; $counter < $limit; ++$counter) {
3737
yield $handler();
3838
}
39-
40-
self::assertGreaterThan($start + 1, microtime(true));
4139
});
40+
41+
self::assertGreaterThan($start + 1, microtime(true));
4242
}
4343
}

0 commit comments

Comments
 (0)