Tema: id numericos
Ver Mensaje Individual
  #7 (permalink)  
Antiguo 01/06/2013, 15:29
Avatar de bulter
bulter
 
Fecha de Ingreso: enero-2008
Mensajes: 137
Antigüedad: 16 años, 4 meses
Puntos: 20
Respuesta: id numericos

While seria mejor para performance :)

Código PHP:
<?php
error_reporting
(E_ALL);

include(
"./Benchmark.php");
$benchmark = new Benchmark();

$benchmark->SpeedTest("for", function()
                             { 
                                for(
$i 0$i <= 10$i++){} 
                             }, 
10000000);
        
$benchmark->SpeedTest("while", function()
                               { 
                                  
$i 0;
                                  while(
$i++ <= 10){} 
                               }, 
10000000);

print_r($benchmark->CompareAllTimes());                             
?>
Cita:
Array ( [while] => 3.5880300998688 [for] => 4.3773438930511 )