/usr/share/knowledgeroot/include/class-runtime.php is in knowledgeroot 0.9.9.5-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | <?php
/**
* This class is for getting run time values
*
* @package Knowledgeroot
* @author Frank Habermann
* @version $Id$
*
* @example $contenttime = $CLASS['runtime']->start();
* @example echo $contenttime = $CLASS['runtime']->getTime('stop');
* or
* @example $contenttime = $CLASS['runtime']->stop();
* @example echo $contenttime = $CLASS['runtime']->getTime();
*/
class runtime {
var $starttime = 0;
var $stoptime = 0;
var $runtime = 0;
var $startArr = array();
var $stopArr = array();
var $runArr = array();
/**
* start timer
* @param string $name
*/
function start($name = "") {
$this->reset($name);
$timer = microtime();
if($name != "") {
$this->startArr[$name] = ((double)strstr($timer, ' ') + (double)substr($timer,0,strpos($timer,' ')));
} else {
$this->starttime = ((double)strstr($timer, ' ') + (double)substr($timer,0,strpos($timer,' ')));
}
}
/**
* stop timer
* @param string $name
*/
function stop($name = "") {
$timer = microtime();
if($name != "") {
$this->stopArr[$name] = ((double)strstr($timer, ' ') + (double)substr($timer,0,strpos($timer,' ')));
} else {
$this->stoptime = ((double)strstr($timer, ' ') + (double)substr($timer,0,strpos($timer,' ')));
}
}
/**
* return runtime value
*
* @param string $name
* @param mixed $stop - is this set, call stop()
* @return float
*/
function getTime($name = "", $stop = '') {
if ($stop != '') {
$this->stop($name);
}
if($name != "") {
return sprintf('%2.3f', $this->stopArr[$name] - $this->startArr[$name]);
} else {
return sprintf('%2.3f', $this->stoptime - $this->starttime);
}
}
/**
* reset all runtime vars
* @param string $name
* @param bool $clearAll
*/
function reset($name = "", $clearAll = false) {
if($name != "" || $clearAll == true) {
$this->startArr = array();
$this->stopArr = array();
$this->runArr = array();
}
if($name == "" || $clearAll == true) {
$this->starttime = 0;
$this->stoptime = 0;
$this->runtime = 0;
}
}
}
?>
|