note 55650 added to function.unset
| From: | el_albo87 at hotmail dot com | Date: | Tue, 09 Aug 2005 17:34:12 +0000 |
| Subject: | note 55650 added to function.unset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93327@lists.php.net to get a copy of this message | ||
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();
?>
----
Manual Page -- http://www.php.net/manual/en/function.unset.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55650
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55650&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55650&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55650&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55650&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55650&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55650&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55650&report=yes
Search -- http://master.php.net/manage/user-notes.php