<?php
function getmicrotime(){
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
require_once 'Services/W3C/HTMLValidator.php';
$strona = "http://it-maniak.pl/";
echo '<h1>Linki znalezione na '. $strona .'</h1>'; $stripped_file = strip_tags($original_file, "<a>"); preg_match_all('#href="(http://[^/"]+[/]?)"#is', $stripped_file, $matches);
$unikat = array_unique($matches[1
]); //Usuwa powtarzajace sie wartosci
function ClearArray($arr) //Czysci tablice z pustych kluczy
{
foreach($arr as $val)
{
{
$cleared_arr[] = $val;
}
}
return $cleared_arr;
}
$tablica = ClearArray($unikat);
$poprawne = 0;
for ($i = 0; $i < count($tablica); $i++) {
echo $tablica[$i].' <a href="http://validator.w3.org/check?uri='.$tablica[$i].'">Validacja</a>'; /*$v = new Services_W3C_HTMLValidator();
$u = $tablica[$i];
$r = $v->validate($u);
if ($r->isValid()) {
echo ' <font color="green"><b>Valid!</b></font><br />';
$poprawne++;
} else {
echo ' <font color="red">NOT valid!</font> Błędy: '. count($r->errors) .' Ostrzeżenia: '. count($r->warnings) .'<br />';
}*/
}
echo '<br />Poprawne strony: '.$poprawne.'/'.$i;
$time_end = getmicrotime();
$time = substr($time_end - $time_start, 0
, 5
); echo '<br />Strona została wygenerowana w '.$time.' sekund.'; ?>
Czas bez sprawdzania to ok. 0.789s, a ze sprawdzeniem 26 sekund. Jak przyśpieszyć ten skrypt? Wiem, że te API jest wolne (i nie tylko ja mam takie spowolnienie), ale może dałoby się coś wycisnąć więcej z samego kodu np w pętli coś źle dałem.
//Edit:
Dostałem 4-5 sekund więcej przy walidacji dzięki wyrzuceniu
$v = new Services_W3C_HTMLValidator();
poza pętle.
Ten post edytował vegeta 3.02.2011, 23:02:36