Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86481 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31330 invoked from network); 3 Jun 2015 23:34:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jun 2015 23:34:24 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.215.51 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.215.51 mail-la0-f51.google.com Received: from [209.85.215.51] ([209.85.215.51:32983] helo=mail-la0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C8/10-29631-BFE8F655 for ; Wed, 03 Jun 2015 19:34:20 -0400 Received: by labpy14 with SMTP id py14so19886689lab.0 for ; Wed, 03 Jun 2015 16:34:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=sta7p0DxugQ32VzJMmMWliGDj1J3PbnHriCEN4SEAAQ=; b=NeDS+sHFY0jh1bhf0p+5ozX/LpD0LZk4KCuBeHSniZfvTSoJEFPnG0WHsmHwP74CXh 32R9aQjccehIwGIep7GgsR6MoCVCLpbxImrIeUMqy/ktb9cSRbSGg0IQxd30kAHMQMUb txTsnw2bLUjwl22M1cTunXeJ0lj+qCtgQ35lQ8h0NTlScA+4ztsXvsdBUZIBXd48kBaS RSFCbhrruhM7bpIr0tU4yRmrL2jeUa5tMVLOaKVVMsSXbFaCOsmgcV5T1rr5Nx60szI2 jIx067XjyHX/hmpd6dVqNH8MrPbhCde/tUQyDjp4vFwOdmZFK1Y1DY19Y24Mxiu+XW2N 9wEQ== X-Gm-Message-State: ALoCoQkOlpQk+bHsxEMGQO0f3QaOA+jkHn9zc8dkwTsOJ+Fr3jhAWGCxmbYisCRzqbZgy17p8vjJ MIME-Version: 1.0 X-Received: by 10.152.45.98 with SMTP id l2mr35231155lam.77.1433374456833; Wed, 03 Jun 2015 16:34:16 -0700 (PDT) Sender: php@golemon.com Received: by 10.112.11.134 with HTTP; Wed, 3 Jun 2015 16:34:16 -0700 (PDT) X-Originating-IP: [73.189.247.124] In-Reply-To: <556F80CF.40303@moonspot.net> References: <556F80CF.40303@moonspot.net> Date: Wed, 3 Jun 2015 16:34:16 -0700 X-Google-Sender-Auth: C9bkVah6SWXunuUZErvihWeoAM8 Message-ID: To: Brian Moon Cc: Bishop Bettini , PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Method call overhead From: pollita@php.net (Sara Golemon) On Wed, Jun 3, 2015 at 3:33 PM, Brian Moon wrote: > On 6/2/15 22:30 , Bishop Bettini wrote: >> I've measured the overhead for method calls in a variety of environments >> (Amazon, Travis, and 3v4l). The results are reliable and here's 3v4l >> . >> >> Some observations. First, as expected, direct calls are faster than >> static >> object calls, which are faster than object calls. Second, in absolute >> times PHP7 outperforms HHVM3 substantially. Kudos, really impressive. >> >> My question though is on relative times. Method call overhead is >> consistently 50% to 150% over a direct call. Is my experiment invalid, or >> is this overhead expected? Is the overhead in the allocation, >> deallocation, GC? >> > This is a better representation of what you are trying to show. It removes > all the magic call back stuff that could be adding to the slowness you are > seeing. In addition, it does not create a new object on every call for the > object method. Creating a new object is going to explicitly slow things > down. But, it's not related to the call time. > Interesting data. Regarding your original question, I would expect method calls to be somewhat more expensive since even with a known method name there's polymorphism to take into account. I wouldn't expect it to be massively more, but non-zero. I would still recommend using Callgrind as Mike suggested. It's going to give you much more reliable (and useful) time numbers than microtime(). -Sara