Re: Array of current instances count

From: Date: Sat, 30 Mar 2013 08:06:19 +0000
Subject: Re: Array of current instances count
References: 1 2  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 03/30/2013 07:45 AM, Joe Watkins wrote:
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 zts working ...


Thread (3 messages)

« previous php.internals (#66860) next »