From b7a84c85d1140dc4a8af08edd77d672e582bc0c5 Mon Sep 17 00:00:00 2001 From: Daniel Vedder <daniel.vedder@idiv.de> Date: Mon, 5 Aug 2024 11:03:27 +0200 Subject: [PATCH] Profiled a run, turned off flocking behaviour in skylarks Searching for neighbours turned out to consume ~80% of processing time... --- Makefile | 8 ++++---- runprofile.jl | 4 ++-- src/nature/species/skylark.jl | 9 +++++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 91edc67..2a26fec 100644 --- a/Makefile +++ b/Makefile @@ -23,16 +23,16 @@ docs: profile: # run and profile an example simulation - if [ -d "example_results" ]; then rm -r example_results; fi - ./runprofile.jl -o example_results + if [ -d "profile_results" ]; then rm -r profile_results; fi + ./runprofile.jl -o profile_results container: #TODO create a Singularity container - echo "Not yet implemented (#43)" + echo "Not yet implemented (#43)." release: echo "Not yet implemented." install: #TODO install Julia and/or package dependencies? - echo "Not yet implemented." + echo "Not yet implemented (#67)." diff --git a/runprofile.jl b/runprofile.jl index a223bfd..ff21e0f 100755 --- a/runprofile.jl +++ b/runprofile.jl @@ -11,11 +11,11 @@ Profile.clear() @profile simulate() -open("profile_flat.txt", "w") do s +open("profile_results/profile_flat.txt", "w") do s Profile.print(IOContext(s, :displaysize=>(300,145)), format=:flat, mincount=10, sortedby=:count) end -open("profile_tree.txt", "w") do s +open("profile_results/profile_tree.txt", "w") do s Profile.print(IOContext(s, :displaysize=>(300,300)), mincount=10) end diff --git a/src/nature/species/skylark.jl b/src/nature/species/skylark.jl index 94c3bd1..87ac542 100644 --- a/src/nature/species/skylark.jl +++ b/src/nature/species/skylark.jl @@ -88,9 +88,14 @@ end Non-breeding adults move around with other individuals and check for migration. """ @phase Skylark nonbreeding begin - #XXX is flocking behaviour important? It may be quite computationally expensive... + #FIXME searching for neighbours is *the* performance bottleneck!! + # Two options: + # (a) ignore flocking, simply move randomly (scientifically OK, doesn't look as good) + # (b) select a random neighbour once, then keep following that individual + # flocking behaviour - follow a random neighbour or move randomly - neighbours = @neighbours(self.visionrange) #XXX check for the closest neighbour(s)? + neighbours = () + #neighbours = @neighbours(self.visionrange) #XXX check for the closest neighbour(s)? isempty(neighbours) ? @walk("random", self.movementrange) : @follow(@rand(neighbours), 30m) #XXX magic number -- GitLab