richelbilderbeek / djog_unos_2018

Project by the Uno's at DJOG 2018-2019: Nature Zen
GNU General Public License v3.0
6 stars 2 forks source link

Rob: prepare for decent profiling #491

Closed richelbilderbeek closed 5 years ago

richelbilderbeek commented 5 years ago

Is your feature request related to a problem? Please describe.

Currently, the game gets slower when there are more agents.

@robkruger, to person responsible for profiling, added profiling to the Travis log:

$ gprof djog_unos_2018 > gprof.log
The command "gprof djog_unos_2018 > gprof.log" exited with 0.
0.01s$ head gprof.log -n 1000
Flat profile:
Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 50.00      0.01     0.01    30094     0.00     0.00  agent::move_to_food(game&)
 50.00      0.02     0.01     9160     0.00     0.00  agent::damage_near_grass(game&, agent_type)
  0.00      0.02     0.00  1214166     0.00     0.00  can_eat(agent_type)
  0.00      0.02     0.00   146323     0.00     0.00  sfml_resources::get()
  0.00      0.02     0.00   136065     0.00     0.00  sfml_resources::get_agent_sprite(agent const&)
  0.00      0.02     0.00   118695     0.00     0.00  is_plant(agent_type)
[etcetera]

There is a clear hint which two functions are causing the slowness of the game. But there are some things missing.

Describe the solution you'd like

Then you are prepared to do some decent profiling, as you will be able to measure if a change in the code did indeed speed up the code :+1:

Describe alternatives you've considered

None.

Additional context

None.

richelbilderbeek commented 5 years ago

Well done!

Now we see in the Travis CI log:

97.24s$ time ./djog_unos_2018 --profiling
[...]
real    1m37.234s
user    2m5.632s
sys 0m7.252s

Drawback here is that the experiment is still imperfect, as new agents get added and removed all the time. Cleaner would be is to have a constant, big amount of agents.

Setup a better experiment with the --profile flag (great addition!), in which there are e.g. 100 tiles, 1000 agents, spawning turned off, and -if possible- that they do never interact. Next step after solving this :+1:

robkruger commented 5 years ago

What do you mean with never interact?

richelbilderbeek commented 5 years ago

Sorry for the confusion: I meant that that the agents do not eat/damage each other, so that their number remains constant.

richelbilderbeek commented 5 years ago

When done, close this Issue and continue at #495 :+1: