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

From: Date: Mon, 09 Jan 2017 15:52:35 +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-97627@lists.php.net to get a copy of this message
Lauri Kenttä <lauri.kentta@gmail.com> writes: >> signed 32 bit int range. This version is as fast as php_combined_lcg() >> version on my system. Both versions executes a million uniqid() calls >> about 0.36 sec. >> >> $ php -r '$s = microtime(TRUE);for($i=0;$i<1000000;$i++) uniqid("", >> TRUE); echo microtime(TRUE) - $s;' >> >> 0.36102104187012 >> >> So above patch would be the final patch. I don't expect issues but if >> there is performace issue on some systems, we may consider Lauri's >> integer computation version. > > 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. I have same result; integer version is 0.65 seconds and double version is 0.82 seconds. -- Kazuo Oishi

« previous php.internals (#97627) next »