Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from artur-graniszewski/develop
Release of 1.6.1
- Loading branch information
Showing
42 changed files
with
466 additions
and
801 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
namespace ZeusBench\Ipc; | ||
|
||
use Athletic\AthleticEvent as Event; | ||
use Zend\Log\Logger; | ||
use Zend\Log\Writer\Noop; | ||
use Zeus\Kernel\IpcServer\Adapter\ApcAdapter; | ||
use Zeus\Kernel\IpcServer\Adapter\IpcAdapterInterface; | ||
use ZeusTest\Helpers\ZeusFactories; | ||
|
||
class AthleticEvent extends Event | ||
{ | ||
use ZeusFactories; | ||
|
||
protected $largeMessage; | ||
|
||
protected $mediumMessage; | ||
|
||
protected $smallMessage; | ||
|
||
protected $serviceManager; | ||
|
||
/** @var IpcAdapterInterface */ | ||
protected $ipcAdapter; | ||
|
||
protected $ipcAdapterName = ApcAdapter::class; | ||
|
||
public function __construct() | ||
{ | ||
$logger = new Logger(); | ||
$logger->addWriter(new Noop()); | ||
$this->largeMessage = str_repeat('A', 65536) . "\n"; | ||
$this->mediumMessage = str_repeat('A', 32768) . "\n"; | ||
$this->smallMessage = str_repeat('A', 4096) . "\n"; | ||
$this->serviceManager = $this->getServiceManager(); | ||
$this->ipcAdapter = $this->serviceManager->build(IpcAdapterInterface::class, ['logger_adapter' => $logger, 'ipc_adapter' => $this->ipcAdapterName, 'service_name' => 'zeus-test-' . md5(microtime(true))]); | ||
|
||
$adapter = $this->ipcAdapter; | ||
if (!$adapter->isSupported()) { | ||
throw new \RuntimeException('The PHP configuration or OS system does not support ' . get_class($adapter)); | ||
} | ||
$adapter->connect(); | ||
} | ||
|
||
public function __destruct() | ||
{ | ||
$this->ipcAdapter->disconnect(); | ||
} | ||
|
||
/** | ||
* @iterations 1000 | ||
*/ | ||
public function testSmallMessage() | ||
{ | ||
$this->ipcAdapter->useChannelNumber(0); | ||
$this->ipcAdapter->send($this->smallMessage); | ||
$this->ipcAdapter->useChannelNumber(1); | ||
$message = $this->ipcAdapter->receive(); | ||
if ($message !== $this->smallMessage) { | ||
throw new \Exception('Small message is corrupted'); | ||
} | ||
} | ||
|
||
/** | ||
* @iterations 1000 | ||
*/ | ||
public function testMediumMessage() | ||
{ | ||
$this->ipcAdapter->useChannelNumber(0); | ||
$this->ipcAdapter->send($this->mediumMessage); | ||
$this->ipcAdapter->useChannelNumber(1); | ||
$message = $this->ipcAdapter->receive(); | ||
if ($message !== $this->mediumMessage) { | ||
throw new \Exception('Medium message is corrupted'); | ||
} | ||
} | ||
|
||
/** | ||
* @iterations 1000 | ||
*/ | ||
public function testLargeMessage() | ||
{ | ||
$this->ipcAdapter->useChannelNumber(0); | ||
$this->ipcAdapter->send($this->largeMessage); | ||
$this->ipcAdapter->useChannelNumber(1); | ||
$message = $this->ipcAdapter->receive(); | ||
if ($message !== $this->largeMessage) { | ||
throw new \Exception('Large message is corrupted'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.