public function timestampAsTable()
    {

        // Set up the table
        $first = $this->timestamp[0]['when'];
        $last = $this->timestamp[count($this->timestamp) - 1]['when'];
        $html = "<table class='logtable'><caption>Timestamps</caption><tr><th>Domain</th><th>Where</th><th>When (sec)</th><th>Duration (sec)</th><th>Percent</th><th>Memory (MB)</th><th>Memory peak (MB)</th><th>Comment</th></tr>";
        $right = ' style="text-align: right;"';
        $total = array('domain' => array(), 'where' => array());

        $totalDuration = $last - $first;

        // Create the main table
        foreach ($this->timestamp as $val) {
            $when     = $val['when'] - $first;
            $duration = round($val['duration'], $this->precision);
            $percent  = round(($when) / $totalDuration * 100);
            $memory   = round($val['memory'] / 1024 / 1024, 2);
            $peak     = isset($val['memory-peak']) ? round($val['memory-peak'] / 1024 / 1024, 2): 0;
            $when     = round($when, $this->precision);
            $html .= "<tr><td>{$val['domain']}</td><td>{$val['where']}</td><td{$right}>{$when}</td><td{$right}>{$duration}</td><td{$right}>{$percent}</td><td{$right}>{$memory}</td><td{$right}>{$peak}</td><td>{$val['comment']}</td></tr>";
            @$total['domain'][$val['domain']] += $val['duration'];
            @$total['where'][$val['where']] += $val['duration'];
        }

        $html .= "</table><br><table class='logtable'><caption>Duration per domain</caption><tr><th>Domain</th><th>Duration</th><th>Percent</th></tr>";
    
    
        // Create the table grouped by domain   
        arsort($total['domain']);
    
        foreach ($total['domain'] as $key => $val) {
            if ($totalDuration != 0) {
                $percent = round($val / $totalDuration * 100, 1);
            } else {
                $percent = 100;
            }

            $roundedDuration = round($val, $this->precision);
            $html .= "<tr><td>{$key}</td><td>{$roundedDuration}</td><td>{$percent}</td></tr>";
        }

        $html .= "</table><br><table class='logtable'><caption>Duration per area</caption><tr><th>Area</th><th>Duration</th><th>Percent</th></tr>";
    
        // Create the table grouped by area
        arsort($total['where']);

        foreach ($total['where'] as $key => $val) {
            if ($totalDuration != 0) {
                $percent = round($val / $totalDuration * 100, 1);
            } else {
                $percent = 100;
            }  

            $roundedDuration = round($val, $this->precision);
            $html .= "<tr><td>{$key}</td><td>{$roundedDuration}</td><td>{$percent}</td></tr>";
        }

        $html .= "</table>";

        return $html;
    }