Re: Use decent entropy for uniqid($prefix, TRUE)
| From: | Yasuo Ohgaki | Date: | Sun, 08 Jan 2017 20:37:17 +0000 |
| Subject: | Re: Use decent entropy for uniqid($prefix, TRUE) | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-97595@lists.php.net to get a copy of this message | ||
On Mon, Jan 9, 2017 at 5:31 AM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
> On Mon, Jan 9, 2017 at 3:15 AM, Kazuo Oishi <kazuo@o-ishi.jp> 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
>> 48f1a17886d874dc90867c669481804de90509e8)]
>> $ 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.
>
The performance will be improved by reducing multiple PRNG calls to 1.
I'll modify patch later, could you test it with your system?
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net