batcache::timer_stop PHP Method

timer_stop() public method

Defined here because timer_stop() calls number_format_i18n()
public timer_stop ( $display, $precision = 3 )
    function timer_stop($display = 0, $precision = 3)
    {
        global $timestart, $timeend;
        $mtime = microtime();
        $mtime = explode(' ', $mtime);
        $mtime = $mtime[1] + $mtime[0];
        $timeend = $mtime;
        $timetotal = $timeend - $timestart;
        $r = number_format($timetotal, $precision);
        if ($display) {
            echo $r;
        }
        return $r;
    }

Usage Example

Exemplo n.º 1
0
 if ($batcache->cache_control && isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
     $since = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
     if ($batcache->cache['time'] == $since) {
         header('Last-Modified: ' . $_SERVER['HTTP_IF_MODIFIED_SINCE'], true, 304);
         exit;
     }
 }
 // Use the batcache save time for Last-Modified so we can issue "304 Not Modified"
 if ($batcache->cache_control) {
     header('Last-Modified: ' . date('r', $batcache->cache['time']), true);
     header('Cache-Control: max-age=' . ($batcache->max_age - time() + $batcache->cache['time']) . ', must-revalidate', true);
 }
 // Add some debug info just before </head>
 if ($batcache->debug) {
     if (false !== ($tag_position = strpos($batcache->cache['output'], '</head>'))) {
         $tag = "<!--\n\tgenerated " . (time() - $batcache->cache['time']) . " seconds ago\n\tgenerated in " . $batcache->cache['timer'] . " seconds\n\tserved from batcache in " . $batcache->timer_stop(false, 3) . " seconds\n\texpires in " . ($batcache->max_age - time() + $batcache->cache['time']) . " seconds\n-->\n";
         $batcache->cache['output'] = substr($batcache->cache['output'], 0, $tag_position) . $tag . substr($batcache->cache['output'], $tag_position);
     }
 }
 if (!empty($batcache->cache['headers'])) {
     foreach ($batcache->cache['headers'] as $k => $v) {
         header("{$k}: {$v}", true);
     }
 }
 if (!empty($batcache->headers)) {
     foreach ($batcache->headers as $k => $v) {
         if (is_array($v)) {
             header("{$v[0]}: {$v[1]}", false);
         } else {
             header("{$k}: {$v}", true);
         }
All Usage Examples Of batcache::timer_stop