On 03/29/2013 04:50 PM, Frank Liepert wrote:
Hello Internals,
I'm thinking about a new function returning an array of classes and their
individual number of instances. It would look pretty much like the result of
get_declared_classes().
An Example:
print_r (get_instantiated_classes());
// Array ()
$foo = new StdClass;
print_r (get_instantiated_classes());
// Array ( [StdClass] => 1 )
$bar = new StdClass;
print_r (get_instantiated_classes());
// Array ( [StdClass] => 2 )
... and so on
Such a function could be helpful when refactoring and/or optimizing an
application. Just think of implementing the flyweight pattern in parts of an
application, where it is applicable. You could check against precise
numbers, for example when you're expecting the number of instances to
decrease by a certain number. Besides microtime() and get_memory_usage(), it
could be another useful indicator.
Since I'm neither familiar with C nor the Zend Engine, I cannot implement
the feature and do not know, if it is even possible.
But first of all, I'm asking you for your opinions.
Frank
I think there is some merit to that ...
https://gist.github.com/krakjoe/5275773
The question is, why no ZTS ?
NJoy :)
Joe
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php