All pastes #80802 Raw Edit

Macros Challenge

public php v1 · immutable
·published 2006-07-06 20:40 UTC
rendered paste body
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head></head><body style="font-family:Arial, Helvetica, sans-serif; font-size:7px;"><?php$str = '';$str2 = '';$arr = array();$max = 3000;for ($i=0; $i<$max; $i++) {	$str .= '   {$arr['.$i.']}   ';	$str2 .= '   %%arr'.$i.'%%   ';	array_push($arr, mt_rand(0,5000));}$str3 = $str4 = $str2; // for additional tests//////////////////////////////////////////////sleep(1);$t = microtime(true);eval("\$str = \"$str\";");$f = microtime(true) - $t;echo '<font size="+1">$str = </font>'.$str;echo '<br>';echo '<br>';//////////////////////////////////////////////sleep(1);$t = microtime(true);for ($i=0; $i<$max; $i++) {	$str2 = str_replace('%%arr'.$i.'%%',$arr[$i],$str2);}$f2 = microtime(true) - $t;echo '<font size="+1">$str2 = </font>'.$str2;echo '<br>';echo '<br>';//////////////////////////////////////////////sleep(1);$t = microtime(true);$a = explode('%%arr',$str3);for ($i=0, $m=count($a); $i<$m; $i++) {	$pos = strpos($a[$i],'%');	$index = substr($a[$i],0,$pos);	$a[$i] = $arr[(int)$index].substr($a[$i],$pos+2);}$str3 = join('',$a);$f3 = microtime(true) - $t;echo '<font size="+1">$str3 = </font>'.$str3;echo '<br>';echo '<br>';//////////////////////////////////////////////sleep(1);$t = microtime(true);for ($i=0; $i<$max; $i++) {	$str4 = str_replace('%%arr'.$i.'%%',$arr[$i],$str4);}$f4 = microtime(true) - $t;echo '<font size="+1">$str4 = </font>'.$str4;echo '<br>';echo '<br>';echo '<font size="+2">';echo '<br><br>1: '.$f;echo '<br><br>2: '.$f2;echo '<br><br>3: '.$f3;echo '<br><br>4: '.$f4;echo '</font>';?></body></html>