TimingsHandler: added time(Closure) function

I find myself often using try/finally blocks to avoid accidentally forgetting to stop a timer. This allows a cleaner more concise way of doing it.
This commit is contained in:
Dylan K. Taylor 2019-06-11 14:46:19 +01:00
parent 1c69226187
commit f349a58f2b

View File

@ -184,6 +184,12 @@ class TimingsHandler{
}
}
public function time(\Closure $closure) : void{
$this->startTiming();
$closure();
$this->stopTiming();
}
public function reset() : void{
$this->count = 0;
$this->curCount = 0;