Regis Memory Improvement
gzcompress / gzuncompress
It is just very easy. And the performance is great as well.
<?php
namespace JobConsumerPHP;
require __DIR__ . '/../../vendor/autoload.php';
class CompressUtil
{
private $ioc = null;
public function __construct($ioc)
{
// set up ioc container
$this->ioc = $ioc;
}
public function compress($raw){
return gzcompress($raw);
}
public function uncompress($encode){
return gzuncompress($encode);
}
}
Here is the test case
<?php
use \JobConsumerPHP\IOCUtil;
/**
*
* RUNNING_ENV=test phpunit --bootstrap vendor/autoload.php tests/perf/CompressUtilPerfTest
*
* Created by PhpStorm.
* User: carl
* Date: 3/1/17
* Time: 2:57 PM
*/
class CompressUtilPerfTest extends PHPUnit_Framework_TestCase
{
protected $compressUtil;
protected function setUp()
{
$ioc = new IOCUtil();
$this->compressUtil = $ioc->getService("compressUtil");
}
public function testCompress()
{
$raw = " Company Description sample string ";
for ($i = 0; $i < 1000; $i++) {
$encode = $this->compressUtil->compress($raw);
$this->compressUtil->uncompress($encode);
}
}
}
References:
http://labs.octivi.com/how-we-cut-down-memory-usage-by-82/
http://php.net/manual/en/function.gzcompress.php
http://stackoverflow.com/questions/621976/which-compression-method-to-use-in-php
http://stackoverflow.com/questions/3202218/how-does-gzcompress-work
gzcompress / gzuncompress
It is just very easy. And the performance is great as well.
<?php
namespace JobConsumerPHP;
require __DIR__ . '/../../vendor/autoload.php';
class CompressUtil
{
private $ioc = null;
public function __construct($ioc)
{
// set up ioc container
$this->ioc = $ioc;
}
public function compress($raw){
return gzcompress($raw);
}
public function uncompress($encode){
return gzuncompress($encode);
}
}
Here is the test case
<?php
use \JobConsumerPHP\IOCUtil;
/**
*
* RUNNING_ENV=test phpunit --bootstrap vendor/autoload.php tests/perf/CompressUtilPerfTest
*
* Created by PhpStorm.
* User: carl
* Date: 3/1/17
* Time: 2:57 PM
*/
class CompressUtilPerfTest extends PHPUnit_Framework_TestCase
{
protected $compressUtil;
protected function setUp()
{
$ioc = new IOCUtil();
$this->compressUtil = $ioc->getService("compressUtil");
}
public function testCompress()
{
$raw = " Company Description sample string ";
for ($i = 0; $i < 1000; $i++) {
$encode = $this->compressUtil->compress($raw);
$this->compressUtil->uncompress($encode);
}
}
}
References:
http://labs.octivi.com/how-we-cut-down-memory-usage-by-82/
http://php.net/manual/en/function.gzcompress.php
http://stackoverflow.com/questions/621976/which-compression-method-to-use-in-php
http://stackoverflow.com/questions/3202218/how-does-gzcompress-work