note 55650 rejected from function.unset by nlopess
| From: | nlopess@php.net | Date: | Tue, 09 Aug 2005 17:51:26 +0000 |
| Subject: | note 55650 rejected from function.unset by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-93330@lists.php.net to get a copy of this message | ||
Note Submitter: el_albo87 at hotmail dot com
----
Prueben este codigo y diganme por que pasa lo que pasa:
<?php
// Inicia el TIMER
function timer_start() {
global $timeparts,$starttime;
$timeparts = explode(" ",microtime());
$starttime = $timeparts[1].substr($timeparts[0],1);
$timeparts = explode(" ",microtime());
}
// Retorna el TIMER
function time_end() {
global $timeparts,$starttime;
$endtime = $timeparts[1].substr($timeparts[0],1);
$endtime = bcsub($endtime,$starttime,16);
return $endtime;
}
ob_start(); // Output Buffer
// Variables
$n_variables = $_REQUEST['n_variables'];
$n_pruebas = $_REQUEST['n_pruebas'];
// Formulario
echo '<form method="get"
action="',$_SERVER['PHP_SELF'],'">Numero de
Variables:<br><input name="n_variables"
value="',$n_variables,'"><br>Numero de Pruebas:<br><input
name="n_pruebas" value="',$n_pruebas,'"><br><input
type="submit"></form><hr>';
if(isset($_REQUEST['n_variables'])){
// Info
echo '<strong>No. de Pruebas:
</strong>',$n_pruebas,'<br><strong>No. de Variables:
</strong>',$n_variables,'<br><br>';
for ($i = 1; $i <= $n_pruebas ; $i ++){ // Numero de Pruebas
// SIN UNSET
for ($j = 0; $j < $n_variables ; $j ++){ // Numero de Variables x Prueba
timer_start(); // Inicia el Timer
eval ("\$var$j = 'asdfasdfasdfasdfas';"); // Inicia la Var
$suma = bcadd($suma,time_end(),16); // Suma los tiempos...
}
$promedio_not = bcdiv($suma,$n_variables,16); // Obtiene el Promedio x Prueba
// CON UNSET
for ($j = 0; $j < $n_variables ; $j ++){ // Numero de Variables
timer_start(); // Inicia el Timer
eval ("\$var$j = 'asdfasdfasdfasdfas';"); // Inicia la Var
$suma = bcadd($suma,time_end(),16); // Suma los tiempos...
eval ("unset(\$var$j);"); // Elimina la Var
}
$promedio_unset = bcdiv($suma,$n_variables,16); // Obtiene el Promedio x Prueba
$dif = bcdiv($promedio_unset,$promedio_not,16); // Resta los Promedios
if($promedio_unset > $promedio_not){
$color_not = 'FF';
$color_unset = '00';
}else{
$color_not = '00';
$color_unset = 'FF';
}
// Info de la Prueba
echo '<strong>PRUEBA ',$i,': </strong><font
color="#',$color_unset,'0000">Con Unset:
',$promedio_unset,'</font> - <font
color="#',$color_not,'0000">Sin Unset: ',$promedio_not,'
</font>- DIFERENCIA: ',$dif,'<br>';
}
}
ob_end_flush();
?>