1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-26 20:34:40 +01:00

Remove old benchmark scripts

This commit is contained in:
Stephen Coakley 2015-12-13 17:42:24 -06:00
parent b515575a3e
commit d07d3e56ed
7 changed files with 3 additions and 427 deletions

1
.gitattributes vendored
View File

@ -1,4 +1,3 @@
benchmarks export-ignore
tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore

View File

@ -29,7 +29,7 @@ To be as flexible as possible, this library comes with a collection of non-block
The recommended way to install is with the [Composer](http://getcomposer.org/) package manager. (See the [Composer installation guide](https://getcomposer.org/doc/00-intro.md) for information on installing and using Composer.)
Run the following command to use Icicle in your project:
Run the following command to use Icicle in your project:
```bash
composer require icicleio/concurrent
@ -57,14 +57,6 @@ make
sudo make install
```
##### Benchmarks
A few benchmarks are provided for analysis and study. Can be used to back up implementation decisions, or to measure performance on different platforms or hardware.
```bash
vendor/bin/athletic -p benchmarks -b vendor/autoload.php
```
## Documentation
Concurrent can use either process forking, processes created using `proc_open()`, or true threading to parallelize execution. Threading provides better performance and is compatible with Unix and Windows but requires ZTS (Zend thread-safe) PHP, while forking has no external dependencies but is only compatible with Unix systems.
@ -138,7 +130,7 @@ Coroutine\create(function () {
$message = (yield $thread->receive()); // Receive from the context.
yield $thread->join();
print $message . "\n";
});

View File

@ -1,125 +0,0 @@
<?php
namespace Icicle\Benchmarks\Concurrent\Forking;
use Athletic\AthleticEvent;
use Icicle\Concurrent\Forking\SharedObject;
/**
* Profiles reading and writing variables to shared memory using the SharedObject
* class.
*/
class SharedObjectEvent extends AthleticEvent
{
private $sharedObject;
public function classSetUp()
{
$this->sharedObject = new SharedObjectModel();
}
public function classTearDown()
{
$this->sharedObject->destroy();
}
/**
* @iterations 10000
*/
public function construction()
{
$this->sharedObject = new SharedObjectModel();
}
/**
* @iterations 10000
*/
public function readBool()
{
$bool = $this->sharedObject->bool;
}
/**
* @iterations 10000
*/
public function writeBool()
{
$this->sharedObject->bool = true;
}
/**
* @iterations 10000
*/
public function readInt()
{
$int = $this->sharedObject->int;
}
/**
* @iterations 10000
*/
public function writeInt()
{
$this->sharedObject->int = 2;
}
/**
* @iterations 10000
*/
public function readString()
{
$string = $this->sharedObject->string;
}
/**
* @iterations 10000
*/
public function writeString()
{
$this->sharedObject->string = 'world';
}
/**
* @iterations 10000
*/
public function readObject()
{
$object = $this->sharedObject->object;
}
/**
* @iterations 10000
*/
public function writeObject()
{
$this->sharedObject->object = new \stdClass();
}
}
class SharedObjectModel extends SharedObject
{
/**
* @synchronized
*/
public $bool = false;
/**
* @synchronized
*/
public $int = 1;
/**
* @synchronized
*/
public $string = 'hello';
/**
* @synchronized
*/
public $object;
public function __construct()
{
$this->object = new \stdClass();
parent::__construct();
}
}

View File

@ -1,116 +0,0 @@
<?php
namespace Icicle\Benchmarks\Concurrent;
use Athletic\AthleticEvent;
/**
* Profiles reading and writing serialized variables to direct shared memory
* using the shmop extension.
*
* Note that this is meant to compare with ThreadedMemoryEvent, as reading and
* writing using serialized memory is nearly the same regardless of the data
* type.
*/
class SharedMemoryEvent extends AthleticEvent
{
private $shm;
public function classSetUp()
{
$this->shm = shmop_open(ftok(__FILE__, 't'), 'c', 0666, 86400);
$this->write((object) [
'bool' => false,
'int' => 1,
'string' => 'hello',
'object' => new \stdClass(),
]);
}
public function classTearDown()
{
shmop_delete($this->shm);
shmop_close($this->shm);
}
private function read()
{
return unserialize(shmop_read($this->shm, 0, shmop_size($this->shm)));
}
private function write($object)
{
shmop_write($this->shm, serialize($object), 0);
}
/**
* @iterations 10000
*/
public function readBool()
{
$bool = $this->read()->bool;
}
/**
* @iterations 10000
*/
public function writeBool()
{
$object = $this->read();
$object->bool = true;
$this->write($object);
}
/**
* @iterations 10000
*/
public function readInt()
{
$int = $this->read()->int;
}
/**
* @iterations 10000
*/
public function writeInt()
{
$object = $this->read();
$object->int = 2;
$this->write($object);
}
/**
* @iterations 10000
*/
public function readString()
{
$string = $this->read()->string;
}
/**
* @iterations 10000
*/
public function writeString()
{
$object = $this->read();
$object->string = 'world';
$this->write($object);
}
/**
* @iterations 10000
*/
public function readObject()
{
$object = $this->read()->object;
}
/**
* @iterations 10000
*/
public function writeObject()
{
$object = $this->read();
$object->object = new \stdClass();
$this->write($object);
}
}

View File

@ -1,79 +0,0 @@
<?php
namespace Icicle\Benchmarks\Concurrent;
use Athletic\AthleticEvent;
/**
* Profiles sending and receiving serialized data across a local TCP socket.
*/
class SocketPairEvent extends AthleticEvent
{
private $sockets;
public function classSetUp()
{
$this->sockets = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
}
public function classTearDown()
{
fclose($this->sockets[0]);
fclose($this->sockets[1]);
}
/**
* @iterations 1000
*/
public function writeBool()
{
$this->write(true);
$this->read();
}
/**
* @iterations 1000
*/
public function writeInt()
{
$this->write(2);
$this->read();
}
/**
* @iterations 1000
*/
public function writeString()
{
$this->write('world');
$this->read();
}
/**
* @iterations 1000
*/
public function writeObject()
{
$this->write(new \stdClass());
$this->read();
}
private function read()
{
$buffer = '';
while (true) {
$char = fgetc($this->sockets[1]);
if ($char !== chr(0)) {
$buffer .= $char;
}
break;
}
return unserialize($buffer);
}
private function write($value)
{
fwrite($this->sockets[0], serialize($value) . chr(0));
}
}

View File

@ -1,94 +0,0 @@
<?php
namespace Icicle\Benchmarks\Concurrent;
use Athletic\AthleticEvent;
/**
* Profiles reading and writing variables to shared threaded memory using the
* pthreads memory implementation.
*/
class ThreadedMemoryEvent extends AthleticEvent
{
private $threadedObject;
public function classSetUp()
{
$this->threadedObject = new \Threaded();
$this->threadedObject->bool = false;
$this->threadedObject->int = 1;
$this->threadedObject->string = 'hello';
$this->threadedObject->object = new \stdClass();
}
/**
* @iterations 10000
*/
public function readBool()
{
$bool = $this->threadedObject->bool;
}
/**
* @iterations 10000
*/
public function writeBool()
{
$this->threadedObject->bool = true;
}
/**
* @iterations 10000
*/
public function readInt()
{
$int = $this->threadedObject->int;
}
/**
* @iterations 10000
*/
public function writeInt()
{
$this->threadedObject->int = 2;
}
/**
* @iterations 10000
*/
public function readString()
{
$string = $this->threadedObject->string;
}
/**
* @iterations 10000
*/
public function writeString()
{
$this->threadedObject->string = 'world';
}
/**
* @iterations 10000
*/
public function readObject()
{
$object = $this->threadedObject->object;
}
/**
* @iterations 10000
*/
public function writeObject()
{
$this->threadedObject->object = new \stdClass();
}
/**
* @iterations 10000
*/
public function writeThreadedObject()
{
$this->threadedObject->object = new \Threaded();
}
}

View File

@ -23,8 +23,7 @@
"icicleio/stream": "^0.5"
},
"require-dev": {
"phpunit/phpunit": "^4.6",
"athletic/athletic": "^0.1.8"
"phpunit/phpunit": "^4.6"
},
"suggest": {
"ext-pcntl": "Required for fork contexts",