in reply to Re^4: Is rand() really that slow or am I just using it wrong?
in thread Is rand() really that slow or am I just using it wrong?
OK, I'm confused.
You're not confused; you are correct!
I don't know what I did different late last night, but retrieving the same command lines from my console history I used to test this yesterday, that showed my way taking almost half the time, today show it taking ~15% longer.
So, my apologies to the OP and thank you Mr Anonymonk for checking me.
By way of recompense I offer this version which takes 1/4 of the time, at the cost of being very slightly less fair:
my @chars = ('a'..'z', 'A'..'Z',0..9, qw[- _ ! & ? = ] ); sub genFile { my( $fh, $mb ) = @_; my @buf = ( @chars ) x 61; $#buf = 4096; for( 1 .. $mb * 256 ) { print $fh join'', shuffle @buf; } }
|
|---|