Advertisement
Guest User

Untitled

a guest
Feb 12th, 2012
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #per: http://stackoverflow.com/a/853882/747749
  2. #test generating a random string with concatenation. 100,000 runs
  3. time php -r 'function r($length = 16, $charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {$str = "";$count = strlen($charset);while ($length--) {$str .= $charset[mt_rand(0, $count-1)];}echo $str.PHP_EOL;}for($i=0;$i<100000;$i++)r();' > /dev/null
  4.  
  5. #test generating a random string with implode. 100,000 runs
  6. time php -r 'function r($length = 16, $charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {$count = strlen($charset);while ($length--) {$str[] = $charset[mt_rand(0, $count-1)];}echo implode($str).PHP_EOL;}for($i=0;$i<100000;$i++)r();' > /dev/null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement