Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96230 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77555 invoked from network); 4 Oct 2016 15:52:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Oct 2016 15:52:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=michal@brzuchalski.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=michal@brzuchalski.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain brzuchalski.com designates 188.165.245.118 as permitted sender) X-PHP-List-Original-Sender: michal@brzuchalski.com X-Host-Fingerprint: 188.165.245.118 ns220893.ip-188-165-245.eu Received: from [188.165.245.118] ([188.165.245.118:49601] helo=poczta.brzuchalski.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7B/37-06241-330D3F75 for ; Tue, 04 Oct 2016 11:52:20 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id 17A982984238 for ; Tue, 4 Oct 2016 17:52:16 +0200 (CEST) Received: from poczta.brzuchalski.com ([127.0.0.1]) by localhost (poczta.brzuchalski.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lYUBaifwKv7O for ; Tue, 4 Oct 2016 17:52:12 +0200 (CEST) Received: from mail-qk0-f181.google.com (unknown [209.85.220.181]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id 4D6652984236 for ; Tue, 4 Oct 2016 17:52:12 +0200 (CEST) Received: by mail-qk0-f181.google.com with SMTP id t7so195401548qkh.2 for ; Tue, 04 Oct 2016 08:52:12 -0700 (PDT) X-Gm-Message-State: AA6/9Rk+6YJNsULl/Gu5x8idYdg6j+gmTBU6lFKRa2ePyuVCqqLzD0CZnhcFQisyNFWEUt/cLj7BW9NkZK9Mcw== X-Received: by 10.55.33.101 with SMTP id h98mr4712763qkh.201.1475596331435; Tue, 04 Oct 2016 08:52:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.45.238 with HTTP; Tue, 4 Oct 2016 08:52:10 -0700 (PDT) In-Reply-To: References: <004101d21e33$124edf90$36ec9eb0$@lool.fr> <3bc3c57695cdf6207724db47e6dbbbab@koti.fimnet.fi> <000401d21e4c$3e71d140$bb5573c0$@lool.fr> Date: Tue, 4 Oct 2016 17:52:10 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Bob Weinand Cc: Pascal KISSIAN , PHP internals list Content-Type: multipart/alternative; boundary=001a11400a002adb6b053e0c0b73 Subject: Re: [PHP-DEV] Feature Request: inline pseudo-instruction From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --001a11400a002adb6b053e0c0b73 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2016-10-04 17:39 GMT+02:00 Bob Weinand : > > > Am 4.10.2016 um 16:33 schrieb Pascal KISSIAN = : > > > >> -----Message d'origine----- > >> De : Lauri Kentt=C3=A4 [mailto:lauri.kentta@gmail.com] > >> Envoy=C3=A9 : mardi 4 octobre 2016 16:21 > >> =C3=80 : Pascal KISSIAN > >> Cc : internals@lists.php.net > >> Objet : Re: [PHP-DEV] Feature Request: inline pseudo-instruction > >> > >> On 2016-10-04 14:33, Pascal KISSIAN wrote: > >>> I have an application where a small file is included at multiple > >>> places. > >>> > >>> The include is done about an average of 100.000 times . > >> > >> I'm just wondering if you have ever heard of functions? You really > should write a function, include it only once, and then simply call the > function instead of repeatedly >including the file. Calling a function is= a > lot faster than including a file. > >> > >> -- > >> Lauri Kentt=C3=A4 > > > > Function is not appropriate when the "inlined code" has to share 20-30 > local variables ... > > Having a function with 30 args, or having to build and access an array > is not very efficient nor natural... > > Local variables include 6 nested "for loop" indices and local > variables/arrays needed for the computing. > 6-level nested loop and 20-30 local variables in scope has enought complexity to refactor. This stuff definitelly needs refactor. I wouldn't allow any developer to commit such code, it woudn't pass code review. There was time I also have such code but it wasn't maintainable, once written was never beeing understood by any other developer. I think you should read about CleanCode -> https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/013235= 0882 > Hey, > > why do you think are your includes so slow? > Apart from the include itself (which in itself is fairly slow due to > filesystem access; or in case with opcache, at the very least copying the > op_array etc.), it does exactly this: building an array and importing it > into the included files scope. > > Also, 20-30 local variables? That sounds a bit like your code has way too > many responsibilities in one same place. Perhaps you should restructure > your code instead, but the way you describe it, no. > > If your code is so "hot", that also even function calls would be quite > significant then you should probably really inline your code there as a > perf optimization. Anyway, code with that many variables almost always ca= n > meaningfully refactored. > > It is not the languages task to optimize insane code ... > > Bob > > > > > --=20 regards / pozdrawiam, -- Micha=C5=82 Brzuchalski brzuchalski.com --001a11400a002adb6b053e0c0b73--