Skip to content

Commit 4f60fb8

Browse files
Anton Shaboutazloyuser
authored andcommitted
Performance optimizations
1 parent 61f3bb1 commit 4f60fb8

File tree

6 files changed

+422
-300
lines changed

6 files changed

+422
-300
lines changed

examples/basic.php

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,15 @@
2121
/** @var Channel $channel */
2222
$channel = yield $client->channel();
2323

24-
yield $channel->queueDeclare('test_queue', false, false, false, true);
24+
yield $channel->queueDeclare('basic_queue', false, false, false, true);
2525

26-
$body = \str_repeat("a", 10 << 20); // 10 MiB
27-
$body = '';
28-
29-
yield $channel->publish($body, '', 'test_queue');
26+
for ($i = 0; $i < 10; $i++) {
27+
yield $channel->publish("test_$i", '', 'basic_queue');
28+
}
3029

31-
yield $channel->consume(function (Message $message, Channel $channel) use ($body, $client) {
32-
echo 'YAA!';
30+
yield $channel->consume(function (Message $message, Channel $channel) {
31+
echo $message->content() . \PHP_EOL;
3332

3433
yield $channel->ack($message);
35-
// yield $client->disconnect();
36-
}, 'test_queue');
37-
//
38-
// yield $channel->queueDeclare('basic_queue', false, false, false, true);
39-
//
40-
// for ($i = 0; $i < 10; $i++) {
41-
// yield $channel->publish("test_$i", '', 'basic_queue');
42-
// }
43-
//
44-
// yield $channel->consume(function (Message $message, Channel $channel) {
45-
// echo $message->content() . \PHP_EOL;
46-
//
47-
// yield $channel->ack($message);
48-
// }, 'basic_queue');
34+
}, 'basic_queue');
4935
});

0 commit comments

Comments
 (0)