Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
831 florian 1
<?php
2
 
3
////////////////////////////////////////////////////////////////////////////////
4
//                                                                            //
5
//   Copyright (C) 2006  Phorum Development Team                              //
6
//   http://www.phorum.org                                                    //
7
//                                                                            //
8
//   This program is free software. You can redistribute it and/or modify     //
9
//   it under the terms of either the current Phorum License (viewable at     //
10
//   phorum.org) or the Phorum License that was distributed with this file    //
11
//                                                                            //
12
//   This program is distributed in the hope that it will be useful,          //
13
//   but WITHOUT ANY WARRANTY, without even the implied warranty of           //
14
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
15
//                                                                            //
16
//   You should have received a copy of the Phorum License                    //
17
//   along with this program.                                                 //
18
////////////////////////////////////////////////////////////////////////////////
19
 
20
// This library contains some functions that can be used for
21
// code benchmarking. It is not actively in use in the Phorum
22
// core, but its functions are used by the developers once
23
// in a while.
24
 
25
    if(!defined("PHORUM")) return;
26
 
27
    function timing_start($key="default")
28
    {
29
        $GLOBALS["_TIMING"][$key]["start"]=microtime();
30
    }
31
 
32
    function timing_mark($mark, $key="default")
33
    {
34
        $GLOBALS["_TIMING"][$key][$mark]=microtime();
35
    }
36
 
37
    function timing_print($key="default")
38
    {
39
        echo '<table border="1" cellspacing="0" cellpadding="2">';
40
        echo "<tr><th>Mark</th><th>Time</th><th>Elapsed</th></tr>";
41
        foreach($GLOBALS["_TIMING"][$key] as $mark => $mt){
42
            $thistime=array_sum(explode(" ", $mt));
43
            if(isset($lasttime)){
44
                $elapsed=round($thistime-$start, 4);
45
                $curr=round($thistime-$lasttime, 4);
46
                echo "<tr><td>$mark</td><td>$curr sec.</td><td>$elapsed sec.</td></tr>";
47
 
48
 
49
            } else {
50
                $start=$thistime;
51
            }
52
            $lasttime=$thistime;
53
        }
54
        echo "</table>";
55
    }
56
 
57
?>