createFlag functions takes longer then I thought



  • Hello fellow Screepers,

    I recently started profiling and noticed that the createFlag functions have a lot overhead beyond the fixed 0.2 cost. I create unique named Flags btw..

    From screeps-profiler output:

    calls		time		avg		function
    25		11.1		0.443		RoomPosition.createFlag
    25		10.7		0.426		Room.createFlag 
    

    I know 0.443 does not mean the world but is suprising for such a simple function though. Does anybody care to confirm/explain ?

    Regards, DrJamgo



  • Do you have a lot of flags?

    I had a brief look at the source code and it seems to traverse the whole list of flags checking for a name conflict. I'm not sure why it's not using a hash of flag names.



  • @systemparadox I have one flag per creep (marking target location and the like) which is about 15 in total.

    I noticed all Flag functions take that time.. even setColor and setPosition because they infact remove the old flag and create a new one 😕

    I guess that explains matters..