The result of Stopwatch is a report that can be obtained in the object view by calling the getReport()
method:
$stopwatch = new Almasmurad\Stopwatch\Stopwatch();
//... (measured code)
$report = $stopwatch->getReport();
The $report
object provides access to the report components via methods:
method | type | description |
---|---|---|
getStart() |
EventInterface |
Stopwatch countdown beginning event |
getFinish() |
EventInterface |
Stopwatch countdown end event |
getPeriod() |
PeriodInterface |
The time elapsed from the beginning to the end of the countdown |
getSteps() |
StepReportInterface[] |
The Reports of all steps of measurement |
getStep() 1 |
StepReportInterface |
The report of the step by its name |
getStepByIndex() 1 |
StepReportInterface |
The report of the step by its number |
getNotices() |
string[] |
Notices list (see the chapter Notices) |
The component of the StepReportInterface
(\Almasmurad\Stopwatch\Report\Common\StepReportInterface
) - a report one step taken that has the following methods:
метод | тип | описание |
---|---|---|
getName() |
string |
название этапа |
getStart() |
EventInterface |
событие начала отсчёта этапа |
getFinish() |
EventInterface |
событие конца отсчёта этапа |
getPeriod() |
PeriodInterface |
время, прошедшее от начала до конца этапа |
The component of the EventInterface
type (Almasmurad\Stopwatch\Time\Common\EventInterface
) - an event that has the following methods:
method | type | description |
---|---|---|
getTimestamp() |
float |
The date of the event in Unix time format |
getDateTime() |
DateTimeInterface |
The date of the event in the form of a DateTime object |
The component of the PeriodInterface
(Almasmurad\Stopwatch\Period\Common\PeriodInterface
) - a time period that has the following method:
method | type | description |
---|---|---|
getSeconds() |
float |
number of seconds |
Example of using a report object:
$report = $stopwatch->getReport();
$elapsed = $report->getPeriod()->getSeconds();
printf('Wow it spent %f seconds!', $elapsed);