Re: Use decent entropy for uniqid($prefix, TRUE)

From: Date: Mon, 09 Jan 2017 21:07:30 +0000
Subject: Re: Use decent entropy for uniqid($prefix, TRUE)
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-97641@lists.php.net to get a copy of this message
Hi Lauri, On Mon, Jan 9, 2017 at 11:07 PM, Lauri Kenttä <lauri.kentta@gmail.com> 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 least > 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 ”not > invented here”? > > 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

« previous php.internals (#97641) next »