$boucle"; } else { if ($x) return; $boucle = $contexte = ''; } list($usec, $sec) = explode(" ", $m1); list($usec2, $sec2) = explode(" ", $m2); $dt = $sec2 + $usec2 - $sec - $usec; $tt += $dt; $nb++; $q = preg_replace('/([a-z)`])\s+([A-Z])/', "$1\n
$2",spip_htmlentities($query)); $e = sql_explain($query, $serveur); $r = str_replace('Resource id ','',(is_object($result)?get_class($result):$result)); $tableau_des_temps[] = array($dt, $nb, $boucle, $q, $e, $r, $contexte); } function chrono_requete($temps) { $total = 0; $hors = "" . _T('zbug_hors_compilation') . ""; $t = $q = $n = $d = array(); // Totaliser les temps et completer le Explain foreach ($temps as $key => $v) { list($dt, $nb, $boucle, $query, $explain, $res, $contexte) = $v; if (is_array($contexte)) { $k = ($contexte[0] . " $boucle"); include_spip('public/compiler'); $env = reconstruire_contexte_compil($contexte); } else $k = $env = $boucle; $total += $dt; $t[$key] = $dt; $q[$key] = $nb; $d[$k]+= $dt; if ($k) @++$n[$k]; if (!is_array($explain)) $explain = array(); foreach($explain as $j => $v) { $explain[$j] = "$j" . str_replace(';','
',$v) . ""; } $e = "" . "" . "" . "" . "" . join('', $explain) . "
" . $query . "
Time$dt
Order$nb
Res$res
"; $temps[$key] = array($e, $env, $k); } // Trier par temps d'execution decroissant array_multisort($t, SORT_DESC, $q, $temps); arsort($d); $i = 1; $t = array(); // Fabriquer les liens de navigations dans le tableau des temps foreach($temps as $k => $v) { $titre = strip_tags($v[2]); $href = quote_amp($GLOBALS['REQUEST_URI'])."#req$i"; $t[$v[2]][]= " " . "$i" . '' . ((count($t[$v[2]]) % 10 == 9) ? "
" : ''); $i++; } if ($d['']) { $d[$hors] = $d['']; $n[$hors] = $n['']; $t[$hors] = $t['']; } unset($d['']); // Fabriquer le tableau des liens de navigation dans le grand tableau foreach ($d as $k => $v) { $d[$k] = $n[$k] . "$k$v" . join('',$t[$k]); } $navigation = array(_T('zbug_statistiques'), "" . join("\n", $d) . "\n" . (# _request('var_mode_objet') ? '' : ("" . count($temps) . "" . _T('info_total') . '' . $total . ""))); return array($temps, $navigation); } ?>