mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
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:
parent
1c69226187
commit
f349a58f2b
@ -184,6 +184,12 @@ class TimingsHandler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function time(\Closure $closure) : void{
|
||||||
|
$this->startTiming();
|
||||||
|
$closure();
|
||||||
|
$this->stopTiming();
|
||||||
|
}
|
||||||
|
|
||||||
public function reset() : void{
|
public function reset() : void{
|
||||||
$this->count = 0;
|
$this->count = 0;
|
||||||
$this->curCount = 0;
|
$this->curCount = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user