-
Notifications
You must be signed in to change notification settings - Fork 0
/
timer.php
executable file
·56 lines (39 loc) · 1.11 KB
/
timer.php
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
<?php
/* -----------------------------------------------
Brian Suda
brian@suda.co.uk
2002/06/02
Timer Class
version 1.0
Functions:
void timer()
int gettimer()
Variables:
timer_clock
Description:
when you create a new timer class it stores the
current microtime in the variable timer_clock.
The function gettimer() will return the elapsed
time from the creation of the variable to the
current time in microtime.
Usage:
$time = new timer();
// do something
$currtime = $time->gettimer();
echo "the operation took $currtime";
----------------------------------------------- */
class timer {
var $timer_clock;
function timer() {
//construtor to start the timer when the object is created
list($usec, $sec) = explode(" ",microtime());
$this->timer_clock=((float)$usec + (float)$sec);
}
function gettimer(){
// returns the current time elapsed since the object was created
list($usec, $sec) = explode(" ",microtime());
$temp = ((float)$usec + (float)$sec)-$this->timer_clock;
return $temp;
}
}
?>