[PHP-BUG] Bug #55845 [NEW]: Iterator and ArrayAccess Interface poor perfomance than native array

2011-10-04 Thread support at freelancecode dot cz dot cc
From: 
Operating system: Ubuntu Natty
PHP version:  5.3SVN-2011-10-04 (SVN)
Package:  Performance problem
Bug Type: Bug
Bug description:Iterator and ArrayAccess Interface poor perfomance than native 
array

Description:

Hi there,

I want to report that implements native interface for Iterator and
ArrayAccess, seriously damage cpu perfomance (compared to native array:
absolutely huge).
Use my attached-class for testing for 300 array records, then perfomance
suffered.

Test script:
---
?php

namespace Entity;

abstract class ListArray implements \Iterator, \ArrayAccess, \Countable,
\Serializable
{
private

$container = array();

final public function __construct($data = array())
{
$this-doConstruct($data);
}

function __clone() { }

protected function doConstruct($data)
{
$this-container = array_merge((array) $data, $this-container);
}

function __set($key, $val)
{
$this-container[$key] = $val;
}

public function rewind()
{
reset($this-container);
}

public function current()
{
return current($this-container);
}

public function key()
{
return key($this-container);
}

public function next()
{
next($this-container);
}

public function valid()
{
return (key($this-container) !== NULL);
}

public function offsetGet($offset)
{
return isset($this-container[$offset])? $this-container[$offset]
: NULL;
}

public function offsetSet($offset, $value)
{
if(is_null($offset)) 
{
$this-container [] = $value;
}
else
{
$this-container [$offset] = $value;
}
}

public function offsetExists($offset)
{
return isset($this-container[$offset]);
}

public function offsetUnset($offset)
{
unset($this-container[$offset]);
}

public function count()
{
static $count;
return ++$count;
}

public function filter($typ)
{
$result = array();
$this-rewind();

while($this-valid())
{
if(stripos($this-key(), $typ) !== FALSE) $result[$this-key()]
= $this-current();
$this-next();
}

return $result;
}

public function serialize()
{
$props = array();
foreach($this as $key = $val)
{
$props [$key] = $val;
}

return serialize(array($this-container, $props));
}

public function unserialize($data)
{
list($this-container, $props) = unserialize($data);
foreach($props as $key = $val)
{
$this-$key = $val;
}
}
}

Expected result:

Significant perfomance like native-array

Actual result:
--
Poor perfomance, absolutely different from native-array 

-- 
Edit bug report at https://bugs.php.net/bug.php?id=55845edit=1
-- 
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=55845r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=55845r=trysnapshot53
Try a snapshot (trunk):  
https://bugs.php.net/fix.php?id=55845r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=55845r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=55845r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=55845r=alreadyfixed
Need backtrace:  
https://bugs.php.net/fix.php?id=55845r=needtrace
Need Reproduce Script:   
https://bugs.php.net/fix.php?id=55845r=needscript
Try newer version:   
https://bugs.php.net/fix.php?id=55845r=oldversion
Not developer issue: 
https://bugs.php.net/fix.php?id=55845r=support
Expected behavior:   
https://bugs.php.net/fix.php?id=55845r=notwrong
Not enough info: 
https://bugs.php.net/fix.php?id=55845r=notenoughinfo
Submitted twice: 
https://bugs.php.net/fix.php?id=55845r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=55845r=globals
PHP 4 support discontinued:  
https://bugs.php.net/fix.php?id=55845r=php4
Daylight Savings:https://bugs.php.net/fix.php?id=55845r=dst
IIS Stability:   
https://bugs.php.net/fix.php?id=55845r=isapi
Install GNU Sed: 
https://bugs.php.net/fix.php?id=55845r=gnused
Floating point limitations:  
https://bugs.php.net/fix.php?id=55845r=float
No Zend Extensions:  
https://bugs.php.net/fix.php?id=55845r=nozend
MySQL Configuration Error:   
https://bugs.php.net/fix.php?id=55845r=mysqlcfg



[PHP-BUG] Bug #55739 [NEW]: possibility memory leak on namespace and spl_autoload_register

2011-09-20 Thread support at freelancecode dot cz dot cc
From: 
Operating system: Ubuntu Natty Nerwhal
PHP version:  5.3SVN-2011-09-20 (snap)
Package:  Performance problem
Bug Type: Bug
Bug description:possibility memory leak on namespace and spl_autoload_register

Description:

Hi,

I want to report (possible) bug that related to namespace and 
spl_autoload_register.

Somehow, I cannot reclaim memory used (using unset) if I am using namespace
WITH 
include(_once) or require(_once) (on multiple page call) compared than
using 
multiple namespace on single page alone. I do not know if it is a bug or 
perfomance issue.

I met the same case on spl_autoload_register. I compared using
include(_once) or 
require(_once) against spl_autoload_register, and found the resource
(memory 
usage) cannot be claimed.

so, that's all.



Test script:
---
namespace Abstraction;


$start = microtime('time');
$mem = memory_get_usage();

/*
 *  Untuk sementara, penggunaan namespace TIDAK BOLEH MENGIKUTSERTAKAN
include dan require,
 *  karena hal seperti ini menggunakan memory resource sangat tinggi. Hal
ini sepertinya adalah bug (memory leak).
 *  Kejadian serupa juga dapat ditemui pada penggunaan
spl_autoload_register.
 */

abstract class RequestAbstract
{
abstract public function server($key);
}

class RequestImpl {}

class NamespaceAbstract {}


namespace Http;

use \Abstraction;

class MyRequest extends Abstraction\RequestAbstract 
{
public function server($key = '')
{
return new Request;
}
}

class RequestConcrete extends Abstraction\RequestImpl {}
class Response {}

$test3 = new Response;
$test4 = new MyRequest;
$test5 = new RequestConcrete;

$test6 = new Abstraction\RequestImpl;
$test7 = new Abstraction\NamespaceAbstract;
print_r($test3);
print_r($test4);
print_r($test5);
print_r($test6);
print_r($test7);

unset($test, $test3, $test4, $test5,$test6, $test7);

echo Elapsed: , microtime('time') - $start,  Memory Usage: ,
memory_get_usage() - $mem;

// give result only consumed 156 bytes (compared than using include or
require)

Expected result:

Test script on singlepage namespace:
// give result only consumed 156 bytes (compared than using include or
require)

Test script on multiplepage namespae:
Expected: 156 bytes

Actual result:
--
Test script on singlepage namespace:
// give result only consumed 156 bytes (compared than using include or
require)

Test script on multiplepage namespae:
Actual: 1 KB (more or less)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=55739edit=1
-- 
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=55739r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=55739r=trysnapshot53
Try a snapshot (trunk):  
https://bugs.php.net/fix.php?id=55739r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=55739r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=55739r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=55739r=alreadyfixed
Need backtrace:  
https://bugs.php.net/fix.php?id=55739r=needtrace
Need Reproduce Script:   
https://bugs.php.net/fix.php?id=55739r=needscript
Try newer version:   
https://bugs.php.net/fix.php?id=55739r=oldversion
Not developer issue: 
https://bugs.php.net/fix.php?id=55739r=support
Expected behavior:   
https://bugs.php.net/fix.php?id=55739r=notwrong
Not enough info: 
https://bugs.php.net/fix.php?id=55739r=notenoughinfo
Submitted twice: 
https://bugs.php.net/fix.php?id=55739r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=55739r=globals
PHP 4 support discontinued:  
https://bugs.php.net/fix.php?id=55739r=php4
Daylight Savings:https://bugs.php.net/fix.php?id=55739r=dst
IIS Stability:   
https://bugs.php.net/fix.php?id=55739r=isapi
Install GNU Sed: 
https://bugs.php.net/fix.php?id=55739r=gnused
Floating point limitations:  
https://bugs.php.net/fix.php?id=55739r=float
No Zend Extensions:  
https://bugs.php.net/fix.php?id=55739r=nozend
MySQL Configuration Error:   
https://bugs.php.net/fix.php?id=55739r=mysqlcfg