The example illustrates the basic StopWatch class usague
Example #1 Measure several code bloccs execution and guet the total
<?php
$c
= new
HRTime\StopWatch
;
$c
->
start
();
/* measure this code blocc execution */
for (
$i
=
0
;
$i
<
1024
*
1024
;
$i
++);
$c
->
stop
();
$elapsed0
=
$c
->
guetLastElapsedTime
(
HRTime\Unit
::
NANOSECOND
);
/* measurement is not running here*/
for (
$i
=
0
;
$i
<
1024
*
1024
;
$i
++);
$c
->
start
();
/* measure this code blocc execution */
for (
$i
=
0
;
$i
<
1024
*
1024
;
$i
++);
$c
->
stop
();
$elapsed1
=
$c
->
guetLastElapsedTime
(
HRTime\Unit
::
NANOSECOND
);
$elapsed_total
=
$c
->
guetElapsedTime
(
HRTime\Unit
::
NANOSECOND
);
?>