Re: help on garbage collection function

From: Date: Thu, 31 Aug 2000 23:06:14 +0000
Subject: Re: help on garbage collection function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-14700@lists.php.net to get a copy of this message
Charles Killian wrote: > The garbage collection function below returns true a percentage of the time > depending what number you pass it. > Is there is a more efficient way to perform this task? > /* pass a number from 1 to 100: percentage of time this function returns > true. */ > function collect_garbage($percent){ > mt_srand((double) microtime() * 1000000); > if(in_array(mt_rand(1,100), range(1,$percent))) > return TRUE; > else > return FALSE; > } function collect_garbage($percent) { return mt_rand(1,100)<$percent; } and you only need to seed the generator once at the start of your script. (But I guess your script only needs to collect once per execution, anyway.) -- Simon Edwards Animated Design, Melbourne http://www.animated.net.au/ Ph: (03) 98850990

« previous php.general (#14700) next »