Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97641 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15968 invoked from network); 9 Jan 2017 21:08:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jan 2017 21:08:24 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:34338] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9B/62-31343-5CBF3785 for ; Mon, 09 Jan 2017 16:08:23 -0500 Received: (qmail 25504 invoked by uid 89); 9 Jan 2017 21:08:18 -0000 Received: from unknown (HELO mail-wm0-f50.google.com) (yohgaki@ohgaki.net@74.125.82.50) by 0 with ESMTPA; 9 Jan 2017 21:08:18 -0000 Received: by mail-wm0-f50.google.com with SMTP id a197so110377767wmd.0 for ; Mon, 09 Jan 2017 13:08:17 -0800 (PST) X-Gm-Message-State: AIkVDXJ0O+koqR4sMvavvDZWlCnGqqJfLo6VHj55BMRvgu03rYFMArsxDhTbKGv7wC99gQOAuNZ0e38hFUJm4Q== X-Received: by 10.28.57.193 with SMTP id g184mr95727wma.122.1483996090905; Mon, 09 Jan 2017 13:08:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.195.12.8 with HTTP; Mon, 9 Jan 2017 13:07:30 -0800 (PST) In-Reply-To: References: <7500b0c6a50baf49beac70ae01e8b50d@koti.fimnet.fi> <87o9zhju4d.fsf@lil.giraffy.jp> <87k2a5jcx5.fsf@lil.giraffy.jp> Date: Tue, 10 Jan 2017 06:07:30 +0900 X-Gmail-Original-Message-ID: Message-ID: To: =?UTF-8?Q?Lauri_Kentt=C3=A4?= Cc: Kazuo Oishi , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a114a4826d8c2f40545afc3dc Subject: Re: [PHP-DEV] Use decent entropy for uniqid($prefix, TRUE) From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a114a4826d8c2f40545afc3dc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Lauri, On Mon, Jan 9, 2017 at 11:07 PM, Lauri Kentt=C3=A4 wrote: > I can confirm that the integer version is faster (2,6 seconds vs 3,6 > seconds for 1000000 uniqid calls). Testing on ARM (Raspberry Pi) gives > similar results. It's not surprising, since converting to float/double is > not free and formatting a floating-point number is also slower than > formatting an integer. > > Using floating-point numbers has exactly zero benefits, while now at leas= t > two people have reported that integers are faster. I think it's also much > easier to read and understand integers, and your bugs tell the same tale. > So do you have some actual arguments for your version, or is this just = =E2=80=9Dnot > invented here=E2=80=9D? > > Also, I must say that I'm neither for nor agains this change in general; > I'm discussing only the implementation. > Thank you for testing. Both versions yield the same result and code readability is the same. Faster is better. Let's use integer version. BTW, it's surprising that I got roughly the same performance for both php_combined_lcg() and php_random_int() with current system (Fedora 25). I used to get little slower result for php_random_int() with Fedora 24. It seems PRNG gets better. There is no advantage to use php_combined_lcg() on newer systems. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a114a4826d8c2f40545afc3dc--