Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97594 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80441 invoked from network); 8 Jan 2017 20:32:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jan 2017 20:32:18 -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:56874] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5D/CB-31343-0D1A2785 for ; Sun, 08 Jan 2017 15:32:17 -0500 Received: (qmail 56564 invoked by uid 89); 8 Jan 2017 20:32:12 -0000 Received: from unknown (HELO mail-wm0-f53.google.com) (yohgaki@ohgaki.net@74.125.82.53) by 0 with ESMTPA; 8 Jan 2017 20:32:12 -0000 Received: by mail-wm0-f53.google.com with SMTP id c206so7235135wme.0 for ; Sun, 08 Jan 2017 12:32:12 -0800 (PST) X-Gm-Message-State: AIkVDXLnj/HhQz171Sy8WoMB+jGdJwKejwvPK8Mqp4iD1D5+3b/wE6LVm+hqf8wxr+xteP1E13wIuR1DcEZ2Dg== X-Received: by 10.223.164.130 with SMTP id g2mr9027907wrb.84.1483907526617; Sun, 08 Jan 2017 12:32:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.195.12.8 with HTTP; Sun, 8 Jan 2017 12:31:26 -0800 (PST) In-Reply-To: <87o9zhju4d.fsf@lil.giraffy.jp> References: <7500b0c6a50baf49beac70ae01e8b50d@koti.fimnet.fi> <87o9zhju4d.fsf@lil.giraffy.jp> Date: Mon, 9 Jan 2017 05:31:26 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Kazuo Oishi Cc: =?UTF-8?Q?Lauri_Kentt=C3=A4?= , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=f403045f24e000f53605459b25b0 Subject: Re: [PHP-DEV] Use decent entropy for uniqid($prefix, TRUE) From: yohgaki@ohgaki.net (Yasuo Ohgaki) --f403045f24e000f53605459b25b0 Content-Type: text/plain; charset=UTF-8 Hi Kazuo, On Mon, Jan 9, 2017 at 3:15 AM, Kazuo Oishi wrote: > No. Lauri's version is better. > > Your php_random_bytes_throw() version is significantly slow. Lauri's > version is faster and cleaner. > > [original uniqid() using php_combined_lcg] > $ time ./php_uniqid_orig -r 'for($i=0; $i<1000000;$i++) uniqid("",true);' > real 0m0.366s > user 0m0.350s > sys 0m0.010s > > [your php_random_bytes_throw version (commit 48f1a17886d874dc90867c66948180 > 4de90509e8)] > $ time ./php_uniqid_yohgaki -r 'for($i=0; $i<1000000;$i++) > uniqid("",true);' > real 0m4.509s > user 0m0.430s > sys 0m4.070s > > [Lauri's php_random_int version] > $ time ./php_uniqid_lauri -r 'for($i=0; $i<1000000;$i++) uniqid("",true);' > real 0m0.664s > user 0m0.260s > sys 0m0.400s > Interesting result. AFAIK, I didn't get significant difference when I made the patch. What is your system? It seems your PRNG is significantly slow. BTW, my patch is extension in mind. i.e. Use of non numeric chars Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --f403045f24e000f53605459b25b0--