Réponse acceptée !
Hello
Voici le résultat d'un bench realisé. Apparemment, c'est 50/50. Il y a peu de différences ... on note toutefois que l'indirect est un chouia (très legers) plus rapide (Les 900 premiers benchs on été à 50/50, après un écart s'est formé).
Et puis ce n'est qu'un tableau à 1001 valeurs ^^
Bench 1
$array = range(0, 1000);
foreach ($array as $key => $value)
{
}
Bench 2
foreach (range(0, 1000) as $key => $value)
{
}
Après 6645 benchs (= 6645 * 1000 = 6.645.000 exécutions)
Stats Bench 1
- Temps total : 18777.09071 s
- Temps par itérations : 0.00283 s
Stats Bench 2
- Temps total : 20692.81719 s
- Temps par itérations : 0.00311 s
Si ma reponse te convient, merci de l'accepter ! 