Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66857 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7151 invoked from network); 29 Mar 2013 16:50:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Mar 2013 16:50:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=frank.liepert@gmx.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=Frank.Liepert@gmx.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.17.21 as permitted sender) X-PHP-List-Original-Sender: frank.liepert@gmx.de X-Host-Fingerprint: 212.227.17.21 mout.gmx.net Received: from [212.227.17.21] ([212.227.17.21:49198] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/62-22694-856C5515 for ; Fri, 29 Mar 2013 11:50:33 -0500 Received: from mailout-de.gmx.net ([10.1.76.31]) by mrigmx.server.lan (mrigmx002) with ESMTP (Nemesis) id 0McCSH-1U37cQ3VBv-00JYgX for ; Fri, 29 Mar 2013 17:50:29 +0100 Received: (qmail invoked by alias); 29 Mar 2013 16:50:29 -0000 Received: from p549B117B.dip.t-dialin.net (EHLO FrankPC) [84.155.17.123] by mail.gmx.net (mp031) with SMTP; 29 Mar 2013 17:50:29 +0100 X-Authenticated: #18131098 X-Provags-ID: V01U2FsdGVkX1/QjRRr+M3QfT49hffdnriZNAOhBQFeXxvXkBHN3N OUm3vRgktZKxly To: Date: Fri, 29 Mar 2013 17:50:29 +0100 Message-ID: <000e01ce2c9d$85864560$9092d020$@Liepert@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac4snYTUGFpU8ExRSSK1NUJ5jK8dew== Content-Language: de X-Y-GMX-Trusted: 0 Subject: Array of current instances count From: Frank.Liepert@gmx.de ("Frank Liepert") 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