From 94d8f59484230ac81a8086d719fdc566be7e7089 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 5 Sep 2020 22:25:42 +0100 Subject: [PATCH] LightUpdate::execute() now returns the number of visits made to blocks in total this is useful for performance profiling. --- src/world/light/LightUpdate.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/world/light/LightUpdate.php b/src/world/light/LightUpdate.php index 914f62a90..03a70ad5c 100644 --- a/src/world/light/LightUpdate.php +++ b/src/world/light/LightUpdate.php @@ -129,10 +129,12 @@ abstract class LightUpdate{ } } - public function execute() : void{ + public function execute() : int{ $this->prepareNodes(); + $touched = 0; while(!$this->removalQueue->isEmpty()){ + $touched++; list($x, $y, $z, $oldAdjacentLight) = $this->removalQueue->dequeue(); $points = [ @@ -155,6 +157,7 @@ abstract class LightUpdate{ } while(!$this->spreadQueue->isEmpty()){ + $touched++; list($x, $y, $z) = $this->spreadQueue->dequeue(); unset($this->spreadVisited[World::blockHash($x, $y, $z)]); @@ -179,6 +182,8 @@ abstract class LightUpdate{ } } } + + return $touched; } protected function computeRemoveLight(int $x, int $y, int $z, int $oldAdjacentLevel) : void{