Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84660 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43116 invoked from network); 13 Mar 2015 00:33:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Mar 2015 00:33:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.17.22 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.17.22 mout.gmx.net Received: from [212.227.17.22] ([212.227.17.22:64324] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F1/E8-24603-E4032055 for ; Thu, 12 Mar 2015 19:33:19 -0500 Received: from [192.168.0.101] ([91.67.244.80]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0M4o41-1ZVBx92ecP-00yyq9; Fri, 13 Mar 2015 01:33:14 +0100 Message-ID: <55023052.40100@gmx.de> Date: Fri, 13 Mar 2015 01:33:22 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Johannes Ott , internals@lists.php.net References: <6D.2C.32765.10EC0055@pb1.pair.com> <5500D967.5040800@gmail.com> <13.69.64353.73451055@pb1.pair.com> <5501876C.3020107@gmail.com> <3D.85.42021.3E7A1055@pb1.pair.com> <5501B77D.5010800@gmail.com> <85.D1.24603.247C1055@pb1.pair.com> <5501D328.9040800@gmail.com> <98.26.24603.C9DE1055@pb1.pair.com> <5501F823.3060805@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:VSJeOYQuSA7wjwQMyS8xWNavhUp9BERY9yzzEjZx35mDKhEydmA Mv/SbCQZ29Rqp96h9TgJTzgj96hsXj3DDA3Ve7nFI/O/O1mbbypVfXdjxfoRUAPmGQ+Bkvf 25XmUEb0et8U70RfroiLG113FyDI/gDCz2lJTktvNaBzjnv/8s08gGI1GyH8S3YjaOI0JFE klc8SMpX63yy3gEhXKC9Q== X-UI-Out-Filterresults: notjunk:1; Subject: Re: [PHP-DEV] static constructor From: cmbecker69@gmx.de (Christoph Becker) Johannes Ott wrote: > And i although see no DI or Singleton pattern to use here to get the > same functionality, if you want to use like Config::getHostname() and > not like Config::getInstance()->getHostname() which is really > unnecessary abstraction level for nothing in my opinion! It is possible, however, to add static wrapper methods to access the singleton's methods, like public static function getHostname() { return self::getInstance()->_getHostname(); } > It is not only about the extra method-call but although the additional > Null check inside this method call. > > Let's do some calculation for that: in average I have 5 calls of the > logger per method the message is used 10 times during the programm. > Now we already have 49 unnecessary method calls (with all needed to do > for the interpreter like preparing stack, copying the returns etc.) and > 40 unnecassary null checks inside (as we agreed before that is not > counted fully, because the evaluation of the flag will although take > some time but can be more efficient inside the interpreter). Let's now > think only about 10 such methods we are already at a count of 490 > unnecessary method calls. Maybe only slightly worse performance but it > is a performance issue! And there is this very old performance rule: a > lot of small performance issues can become quickly to a huge one. > > I have counted the calls in code of self::$LOG-> inside one small > private webproject of mine with less logging implemented yet. But there > are already 128 calls. If you multiply by 10 you already have 1280 calls > on runtime, I think that is a performance issue. It seems to me that the logger example is not appropriate to show performance penalties due to unnecessary method calls and null checks, because the actual task of the logger (write to a file/database, or even send an email) is easily much more demanding performance-wise. Anyhow, in my humble opionion, there had been enough initial discussion on this idea, and it would be reasonable to proceed with the actual RFC. See "How To Create an RFC"[1] and especially "The Mysterious PHP RFC Process and How You Can Change the Web"[2]. :) [1] [2] -- Christoph M. Becker