Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66860 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49076 invoked from network); 30 Mar 2013 08:06:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2013 08:06:24 -0000 X-Host-Fingerprint: 86.14.252.140 cpc3-asfd3-2-0-cust139.1-2.cable.virginmedia.com Received: from [86.14.252.140] ([86.14.252.140:15025] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F9/77-22694-FFC96515 for ; Sat, 30 Mar 2013 03:06:23 -0500 Message-ID: To: internals@lists.php.net Date: Sat, 30 Mar 2013 08:06:19 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 MIME-Version: 1.0 References: <000e01ce2c9d$85864560$9092d020$@Liepert@gmx.de> <51569834.7090707@php.net> In-Reply-To: <51569834.7090707@php.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 86.14.252.140 Subject: Re: Array of current instances count From: krakjoe@php.net (Joe Watkins) 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 ...