ID:2062184
 
(See the best response by Lummox JR.)
Problem description:So guys idk whats wrong, after add to my new enemi the posibility of cloth them with ingame items exactly same as the player ( i dont know if you have ever played New Era or Age of Pirates, that if you dress up any item all the movments of the item are done by a code... ) so with that i dont have to add manually the icon of the item to the mob, its just add the item type to the list and all its done...
The problem comes when i add to the world ( map ) a quantity of mobs, more mobs i add more time takes the game to load and higher is the laggg.
If i delete the Clothes list the game loads really fast and free of lag.
Any idea about how can i fix it?

An example:Without the Clothes Run the game from DM takes me 2s, With 20s. Without, move my player takes me 0.1s with 0.5s +/-

Enemi Code:
mob
NPC
Enemies/Humans
henge = 0
Marines
Marine
name = "Lv80 Marine"
Health = 1000
Max_Health = 1000
IsEnemy = 1
Race = "Human"
gender = "male"
//------ Stats ------
Will_Power_Lvl = 10
Stamina_Lvl = 15
Endurance_Lvl = 29
Strength_Lvl = 30
Speed_Lvl = 6
//------ Combat -------
Attack = 45
Armor = 25
//------ Drops -------
Exp_Drop = 2000
Berry_Drop = 2000
Bounty_Drop = 1200
//-----------------------///// Items Invenorty /////-----------------------//
Clothes = list(new/obj/Items/Clothes/MarineSet/Marine_Shirt,new/obj/Items/Clothes/MarineSet/Marine_Pants,new/obj/Items/Clothes/MarineSet/Marine_Cap,new/obj/Items/Clothes/MarineSet/Marine_Boot/Left,new/obj/Items/Clothes/MarineSet/Marine_Boot/Right)
New()
..()
xxx=src.x
yyy=src.y
zzz=src.z
src.spawnloc = src.loc
overlays = initial(overlays)
Display()
MarineMove()
Bump(mob/M)
..()
LookforPirate(M)

Cant the problem be every new called on Clothes list cuz of creating 7 new items per mob every time that the mob is created? cant the list have constant values or its just me imagining rare things? :))) well i think on that cuz if i have 30 mobs on the map and every mob will create 7 new items on theyr clothes on every respawn that can make lag, or no?

Sry for bad eng pls if you dont understand just tell me pls
Setting a list at compile-time means that the mob will be given a hidden "init" proc that creates the list for you, each time the mob is created. I would strongly recommend moving that list initialization into New() instead.

However, even better is if you don't init the list until you need it. If these marines just have the equipment for show, why not just set their overlays instead?

However, I don't think the code as it stands now is likely to create lag on the magnitude you're seeing, unless each of those items also has a New() or init proc--in which case yeah, you're adding a lot more proc runs to the game at startup. It seems more likely that something else in your code is causing the slowdown, particularly the one you mentioned that happens when moving. In order to find that, I recommend using the built-in profiler so you can see which procs are taking the most time to operate while you move around.
                                  Profile results (total time)
Proc Name Self CPU Total CPU Real Time Calls
-------------------------------------------- --------- --------- --------- ---------
/obj/Items/Den_Den_Mushi/New 0.001 0.010 249.292 48
/obj/Items/Den_Den_Mushi/proc/Update_Suffix 0.009 0.009 249.291 48
/mob/proc/Grid_Display 0.009 0.009 19.168 97
/mob/proc/Screen_Stats 0.011 0.011 10.579 97
/mob/proc/Walk 0.001 0.001 5.695 47
/client/North 0.000 0.001 5.231 45
/mob/proc/Calc_Stats 0.355 1.387 1.383 9342
/mob/proc/Extra_Stats 0.809 1.019 1.015 6300
/mob/Move 0.365 0.871 0.875 10403
/client/West 0.000 0.000 0.464 2
/mob/Bumped 0.114 0.431 0.431 2809
/atom/movable/Bump 0.118 0.409 0.415 10150
/mob/NPC/Enemies/Domestic/Cow/Bump 0.024 0.357 0.361 6625
/mob/proc/Level_Stats 0.224 0.225 0.225 9342
/mob/proc/Skills 0.156 0.185 0.185 6300
/mob/proc/In_Water 0.118 0.121 0.140 22365
/mob/proc/Take_Damage 0.104 0.104 0.101 2620
/mob/NPC/Enemies/Domestic/Chicken/Bump 0.015 0.081 0.083 3102
/mob/proc/Inventory 0.060 0.062 0.066 9342
/mob/proc/Water_Check 0.060 0.060 0.063 9342
/mob/proc/Recovery 0.036 0.037 0.044 9342
/mob/proc/Drowsy 0.036 0.037 0.041 9342
/obj/hudMeters/Stats/Strawhat/Click 0.000 0.000 0.040 1
/obj/Skills/proc/Effect 0.028 0.030 0.040 25200
/mob/proc/GS_Restriction 0.030 0.031 0.037 9342
/mob/proc/Conscious 0.034 0.034 0.035 9342
/mob/proc/Effects 0.026 0.027 0.030 6300
/mob/proc/Save_Timer 0.021 0.023 0.028 9342
/mob/proc/Environmental 0.019 0.021 0.027 9342
/atom/proc/Bumped 0.009 0.012 0.014 7341
/mob/NPC/Enemies/Fierce/Coyote/Bump 0.004 0.012 0.012 234
/mob/NPC/Shops/Shopkeeper/Extra_Stats 0.003 0.003 0.003 234
/mob/NPC/Marine/Extra_Stats 0.002 0.002 0.002 117
/obj/Items/Clothes/New 0.001 0.001 0.002 144
/mob/NPC/Hector/Extra_Stats 0.002 0.002 0.002 234
/mob/NPC/Respawn_Changer/Extra_Stats 0.002 0.002 0.002 234
/mob/Training_Stuff/Training_Log/Extra_Stats 0.002 0.002 0.002 1053
/mob/NPC/Tournament_Manager/Extra_Stats 0.000 0.000 0.001 117
/mob/NPC/Barber/Extra_Stats 0.001 0.001 0.001 234
/area/Enter 0.001 0.001 0.001 222
/mob/proc/Train 0.000 0.000 0.000 10
/mob/NPC/Shops/Petter_The_Smith/Extra_Stats 0.000 0.000 0.000 234
/mob/NPC/Weight_Lifter/Extra_Stats 0.000 0.000 0.000 234
/mob/verb/dInventory 0.000 0.000 0.000 1
/mob/Stat 0.000 0.000 0.000 147
/turf/Click 0.000 0.000 0.000 3
/turf/Click 0.000 0.000 0.000 3
/mob/proc/Loot 0.000 0.000 0.000 98
/mob/NPC/Crew_Manager/Extra_Stats 0.000 0.000 0.000 234
/mob/NPC/Pirate/Extra_Stats 0.000 0.000 0.000 117
/mob/proc/CheckForSkills 0.000 0.000 0.000 29

as i see there after load the game trying to move, i dont have much lag, just a little bit but the game loaded kinda slowly that before use the clothes, can the problem be the den den mushi?? taking me over 249s every one?
Adding the list after the New takes me more time to load the game :O. So now ill try to delete the den den mushi and lets see if its that the problem of the lag
Best response
The high-realtime value in Walk() looks fairly troubling; that's a good candidate. Also those New() and Update_Suffix() routines at the top are probably doing something wrong with sleep/spawn.

I noticed you have a lot of procs running exactly 9342 times, suggesting they're run as part of a global loop. You'd save some proc overhead by combining as many of these as you can into a single proc.
okey kinda better, i combined some procs and loads a little bit faster thx Lummox