Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112685 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 7006 invoked from network); 30 Dec 2020 21:03:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Dec 2020 21:03:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5F29A1804CF for ; Wed, 30 Dec 2020 12:38:34 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, RDNS_NONE,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from wout2-smtp.messagingengine.com (unknown [64.147.123.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 30 Dec 2020 12:38:33 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id E41AA39D for ; Wed, 30 Dec 2020 15:38:22 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute4.internal (MEProxy); Wed, 30 Dec 2020 15:38:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=krOo1EMIyVHKlORq5J80gc3ztSiVUihU7Tegoulnz S8=; b=aCwgsGITwJsZSIZAubE00b3Pz14dv58jLn8i4/K7eyozLDw7++Mrj1PqY IVi7suA2LuYyq8sI9jtEZnhiS3qz0Lbly0fVgFx2VAj6zU643B/opd8MWVS30IVi k/vXDo0f5/8QVihqipAi4Otc/6onLD4PdDt7Va93G9SPpQkNBZbt0DDPt3EHokHj cFB08avBMvqPv49iHLiUwCby/DuJYejFb46qp/Xk+8XVpkK6MHB0SiSDoNWYowBs 6b47cJTtlHps19vmcgD4yVe6p7vGTfs2KTU+TfcnOSbvJojfJ8mK3UXW6HhhzVpE kRB1mvNVOXUTjg89vbkNb0gT+y+Lg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvddvfedgudeflecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepfdfn rghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrd gtohhmqeenucggtffrrghtthgvrhhnpefhkedtfffghfekieduhedvheefgfefheeugfdv leetteektefgteejieeltdelkeenucffohhmrghinhepghhithhhuhgsrdgtohhmnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhies ghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id F1BD214200A2; Wed, 30 Dec 2020 15:38:21 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.1-61-gb52c239-fm-20201210.001-gb52c2396 Mime-Version: 1.0 Message-ID: <20df5745-f2e0-418c-94c1-46bd7712592a@www.fastmail.com> In-Reply-To: References: <1d0abb04-4987-43a9-85bc-bccc3bd6be9a@www.fastmail.com> <03108284-740a-4a5d-130f-15b2e67e9df9@mabe.berlin> <459d7ff7-e553-dce9-7d43-c3b1e772e572@gmail.com> <7f4fe9ca-1c20-6f69-cef0-a9718af742a3@gmail.com> <3e683903-66cb-4a1a-9ff8-22887dbb8dce@www.fastmail.com> Date: Wed, 30 Dec 2020 14:37:58 -0600 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: =?UTF-8?Q?Re:_[PHP-DEV]_Analysis_of_property_visibility,_immutability,_a?= =?UTF-8?Q?nd_cloning_proposals?= From: larry@garfieldtech.com ("Larry Garfield") On Wed, Dec 30, 2020, at 2:16 PM, Olle H=C3=A4rstedt wrote: > > Ok. You have a benchmark for this? I can make one otherwise, for the= query > > example. > > > > It worries me a little that immutablility is pushed into the ecosyst= em as a > > silver bullet. Main reason functional languages are using it is beca= use > > ownership is a newer concept, so it hasn't been adapted as much. >=20 > Tiny benchmark here: > https://gist.github.com/olleharstedt/eaaf1dd40be541f84aa0f3954a0ea54a >=20 > Running this on my ARM machine with PHP 7.2 gives ~1.2s for the > immutable loop, ~0.35s for the mutable one, meaning immutability is > ~3x as expensive performance wise. And this is for a SMALL object - I > suspect the performance hit will grow the bigger the class gets (more > properties to clone). Correct me if I'm wrong. :/ That's not a valid benchmark; it's comparing cloning and method invocati= on against just property sets. The method calls are chewing up most of = the time there. Here's a more fair comparison on my laptop: https://gist.github.com/Crel= l/848568124e25c8c83fc4da5455063bab Which is only ~20% slower. And that's when dealing with very small numb= ers, so in most cases you're unlikely to notice a difference unless you = really are iterating over something a million times. I also tossed some big string properties into the class, and while the t= otal time went up a bit the ratio between the two stayed about the same.= --Larry Garfield