Added optional description to Stopwatch records.
This commit is contained in:
1 parent
63f1b9e216
commit
eb573e143e
1 file changed
+8
-2
@@ -16,13 +16,18 @@ class Stopwatch_Record implements Record_Interface {
|
|||||||
/** @var StopwatchEvent */
|
/** @var StopwatchEvent */
|
||||||
protected $stopwatch_event;
|
protected $stopwatch_event;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $description = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name Event name.
|
* @param string $name Event name.
|
||||||
* @param StopwatchEvent $stopwatch_event Stopwatch event instance.
|
* @param StopwatchEvent $stopwatch_event Stopwatch event instance.
|
||||||
|
* @param string $description Optional description for the event.
|
||||||
*/
|
*/
|
||||||
public function __construct( string $name, StopwatchEvent $stopwatch_event ) {
|
public function __construct( string $name, StopwatchEvent $stopwatch_event, string $description = '' ) {
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->stopwatch_event = $stopwatch_event;
|
$this->stopwatch_event = $stopwatch_event;
|
||||||
|
$this->description = $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,8 +44,9 @@ class Stopwatch_Record implements Record_Interface {
|
|||||||
|
|
||||||
$duration = round( $this->stopwatch_event->getDuration() );
|
$duration = round( $this->stopwatch_event->getDuration() );
|
||||||
$memory = $this->stopwatch_event->getMemory() / 1024 / 1024;
|
$memory = $this->stopwatch_event->getMemory() / 1024 / 1024;
|
||||||
|
$description = '' !== $this->description ? "<hr />{$this->description}" : '';
|
||||||
|
|
||||||
return "{$this->name} – {$duration} ms – {$memory} MB";
|
return "{$this->name} – {$duration} ms – {$memory} MB{$description}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user