Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62258 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80922 invoked from network); 19 Aug 2012 14:46:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2012 14:46:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qc0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:56726] helo=mail-qc0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/71-03087-45CF0305 for ; Sun, 19 Aug 2012 10:46:45 -0400 Received: by qcad42 with SMTP id d42so16477qca.29 for ; Sun, 19 Aug 2012 07:46:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=IguB85h8q1g/dXAFE1wLYsxoLcUg4rHaSBZbka5MtKA=; b=n0qMBW1h/OkReoC8yVYKzgrwcVAqVlSPdKYi8dWaHxnZUNd7K8Tx6LwpEf6hX71GUQ ROjIjUQPyaR/bBQ2wwMBCU0/jsYCBfmy8rjfI91+EWnP6L/IOEqqQ3n8Tsval6hlPvom 5Wo/76Bv9V+L2Hp4YMBi18obGe7XZOUcYObP2tes5F1BKlYlvoRPMJMfnW5zgT9FiwKQ LsVwW8bEQUuld9T7LspyVZPCHwWjTwFohpozXhcAuBDKZJpAxayPBi2fEMqsgbaVYPzt 6aL4vscybZmUOQQq0Xll7yB9w6n62HJsqIylrn76+Q7KsMfIC6jz2vgJSwVMDdTENZJb Iy3Q== MIME-Version: 1.0 Received: by 10.229.105.166 with SMTP id t38mr9563018qco.136.1345387590225; Sun, 19 Aug 2012 07:46:30 -0700 (PDT) Received: by 10.229.54.213 with HTTP; Sun, 19 Aug 2012 07:46:30 -0700 (PDT) In-Reply-To: References: Date: Sun, 19 Aug 2012 10:46:30 -0400 Message-ID: To: Raymond Irving Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=00235429d19066911004c79f7583 Subject: =?windows-1252?Q?Re=3A_=5BPHP=2DDEV=5D_PHP_Performance_=2D_1=92000=92000_iterat?= =?windows-1252?Q?ions?= From: ircmaxell@gmail.com (Anthony Ferrara) --00235429d19066911004c79f7583 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On Sun, Aug 19, 2012 at 10:29 AM, Raymond Irving wrote: > Hello, > > What could have cause PHP to start out so great but then slows to a crawl= ? > Could it be the GC? > > Number of iterations Node.js PHP > --------------------------------------------------------------- > 100 2.00 0.14 > 10=92000 3.00 10.53 > 1=92000=92000 15.00 1119.24 > 10=92000=92000 143.00 10621.46 > 1=92000=92000=92000 11118.00 1036272.19 > > See the script here: > > http://net.tutsplus.com/tutorials/javascript-ajax/node-js-for-beginners/?= utm_source=3Dfeedburner&utm_medium=3Dfeed&utm_campaign=3DFeed%3A+nettuts+%2= 8Nettuts%2B%29 > > Is there any way that this can be improved? > PHP doesn't slow to a crawl. It runs in constant time. You can see that because increasing the iteration count by 2 orders of magnitude increases runtime by two orders of magnitude. What you're seeing with nodejs is v8's JIT compiler in action. The compilation step takes some extra time, which you only see the benefit from in high iteration counts. It compiles the code down to machine code (which prob takes the majority of the time), and then executes it. Where PHP executes the same code each time. Which is why PHP is significantly faster in the shorter iteration counts (it doesn't have the overhead of converting to machine code). Now, it looks like a surprising result. But it's far from a realistic benchmark. For the narrow use-case where you're doing high iteration counts over a simple (to a compiler) instruction set, v8 may be 93% faster. But for the general use case, you won't find that big of a difference... Nothing is free. Everything costs something. And that's the problem with simple benchmarks like this. They hide the cost, and only show you the result. Which is unrelistic at best... Anthony --00235429d19066911004c79f7583--