Example #1
0
function MemL($x = '', $y = 90)
{
    static $i;
    $i++;
    if (!$x) {
        $x = $i;
    }
    return Memuse($y, $x);
}
Example #2
0
function BL2($DIR = './', $type = '.', $exclude = 'µù', $MiT = 1, $MaT = 2115286871, $max = 9999, $MinFS = 0, $keyac = 0, $MaxFS = 99999999)
{
    #whatever
    #USED @ A BAD PLACE ../
    $type = $type ? $type : '.';
    GT('l' . __LINE__);
    memuse();
    $files = scandir($DIR);
    if (!$files) {
        return;
    }
    Memuse();
    //$type="\.jpg|\.gif"
    #[[12-Jan-2012 16:00:31] PHP Fatal error:  Allowed memory size of 209715200 bytes exhausted (tried to allocate 71 bytes) in /home/ovh/fun.php on line 601] => 1
    foreach ($files as $file) {
        if (is_dir($DIR . $file)) {
            continue;
        }
        $w = @filemtime($DIR . $file);
        #if(J9)echo"<li>".(strlen($file)<4).';'.($w<$MiT).';'.$MaxFS.';'.(filesize($DIR.$file)).';'.(filesize($DIR.$file)>$MaxFS);
        if (Preg_Match('~' . $exclude . "|htaccess|index\\.php~is", $file) or strlen($file) < 4 or $w < $MiT or $w > $MaT or filesize($DIR . $file) < $MinFS or filesize($DIR . $file) > $MaxFS) {
            continue;
        }
        if ($type != '.') {
            if (Preg_Match("~{$type}~is", $file)) {
                if ($keyac) {
                    if ($T) {
                        while (array_key_exists($w, $T)) {
                            $w++;
                        }
                    }
                    if (is_file($DIR . $file)) {
                        Touch($DIR . $file, $w);
                    }
                    $T[$w] = $file;
                    $i++;
                } else {
                    $T[] = $file;
                }
            }
        } else {
            $T[] = $file;
        }
    }
    if (count($T) < 1) {
        return;
    }
    if ($keyac) {
        krsort($T);
    }
    if (count($T) > $max) {
        $T = Array_slice($T, 0, $max, 1);
    }
    return $T;
}
Example #3
0
function GT($k = '', $m = 0, $e = 4)
{
    static $noerr, $err, $i, $prevmemusage;
    if (in_Array($k, array('kill', 'cachepath:read:1'))) {
        $noerr = $k;
    }
    #pas d'erreur après ces clés
    #Final-désactivation erreurs si accession au shutdown
    if (!$noerr && ($err || e(',timeerror,timerror,dead1,av', 1))) {
        return;
    }
    #empêche la récursivité de la fonction
    $now = Memuse(90);
    $mem = $now - $prevmemusage;
    $prevmemusage = $now;
    $round = Round($mem, 3);
    Rem($k, DB2(-1), $i);
    #Mettre en clé la Dernière instruction du Debug Backtrace si non définie #$i++;$k='u'.$i;$_ENV['dbt']['#'.$k]=DB2(-1);}
    $x = TimeLong(1);
    if (is_Array($x)) {
        extract($x);
    } else {
        $d = $x;
    }
    if ($d) {
        $_ENV['lasttime'] = $d;
    }
    $_ENV['lastkey'] = $k;
    $i++;
    if ($i > $_ENV['maxop']) {
        $err = 1;
        Db(SU, ">" . Round($d) . " sec; gt-occurences:{$i}");
        jx("mail", SU, ">" . Round($d) . " sec; gt-occurences:{$i}");
    }
    if (in_Array($k, array('000', 'fin'))) {
        return $d * 1000;
    }
    #Multiplions la valeur par mille : 51.4ms
    if (!is_numeric($m) && isset($_ENV['Adbt'][$k]) && $m) {
        $d2 = $d - $_ENV['Adbt'][$k];
        unset($m);
    }
    #prend la différence entre les deux clés : 0.0197-0.0136
    if (!$d2) {
        return;
    }
    #Trop rapprochées&recursive? substr($_ENV['args'],-1)=GT()??
    $d2 = round($d2, 5);
    $d = round($d, 5);
    if (!isset($_ENV['Tdbt'][$key])) {
        $_ENV['Tdbt'][$key] = 0;
    }
    $_ENV['Tdbt'][$key] += $d2;
    if (isset($_ENV['dbt'][$k])) {
        $_ENV['dbt'][$k] += $d2;
    } else {
        $_ENV['dbt'][$k] = $d2;
    }
    $_ENV['Adbt'][$k] = $d;
    #absolue
    if ($round > 0.1) {
        $_ENV['Mem'][$k] = $round;
    }
    #Si 100ko = significative
    if (!isset($_ENV['dbe'])) {
        $_ENV['dbe'] = array('db' => null);
    }
    $d2 = Round($d2 * 1000);
    $d = Round($d * 1000);
    if ($d2 > 5 || $m == 1) {
        $_ENV['dbe']['db'] .= "{$k}:{$d2} ";
    }
    if ($d > 30000 && !ru && !$noerr) {
        e(',timeerror');
        Db(SU, "{$k}>" . Round($d) . " sec ");
        jx('mail', '+30sec');
        return;
    }
    return $d2;
    #Retourne toujours l'écart & non la valeur absolue
}