ID:2253057
 
(See the best response by Nadrew.)
Code:
mob/var/tmp/prePanel
mob/var/tmp/statPanelDelay
var/defaultStatPanelDelay=5
mob/Stat()
for(var/i=1; i<=src.statPanelDelay; i++)
if(src.prePanel!=src.client.statpanel) break
sleep(1)
src.prePanel=src.client.statpanel
src.statPanelDelay=defaultStatPanelDelay


Problem description:
So, three tabs on my stat panel will lag the person in the game. They will freeze and skip until you change tabs. Happens with any byond version (Tested with 511,510, and 509) And only recently started to happen after i increase the player view size (was 8 and is now 12) And i tired tinkering around with the code and had no noticeable results.
solution: don't use stat panels
What should i use then?
It would probably be helpful if you said what you were trying to do as the code you posted makes about zero sense out of context. I'm not even sure what you're trying to do since that piece of code alone is nonsense (and you're forgetting to call ..() in Stat()).

But like Unwanted4Murder said, moving from statpanels to your own hand-rolled information displays (usually onscreen or using grids) is always going to be a better idea.
Like Nadrew said I'm really not sure what you're trying to do but any information you can display in a statpanel can be done to better effect in other ways. You could put them in a custom skin window or just draw them on the screen. If you're not sure where to start, look up the screen_loc variable and the screen (client) variable in the F1 guide.
How would one put stat("text") and categorized stat panel verbs in a custom skin window i have like over 100 verbs. I heavily rely on this statpanel
Best response
Well, you should probably ditch the usage of verb panels and stat panels entirely and move to something that's more modern and butt ass ugly. Things like hotbars, on-screen stat displays, and actual interfaces to call all those verbs from.

However, since there's a pretty solid chance you're not working from your own project source (you have over 100 verbs and don't understand why the above code is nonsense), I'll just tell you that you want an 'info' control.

The reason your code above lags is because it's nonsense, it does nothing but endlessly loop over and over without actually doing anything in the process. Adding the sleep(1) inside of Stat() just made it call even faster (despite it being nested inside of the pointless loop).

You never actually explained what that code was meant to do, and even us experience us reading it are looking at it going "that makes no sense" -- so I doubt it does anything remotely what you think it does.
^ What Nads said. From your responses I'd guess this is a ripped anime game with eight million verbs and you have no idea what any of the code actually does. So my full answer would be to throw what you have in the trash and learn to program instead.
As far as I can tell it's some convoluted (and broken) way to only display a single panel and update it every 5 seconds.

if(statpanel("My Panel"))
stat("Stuff")
sleep(50)


Would do the same thing, but that's just assuming that's actually what he's trying to do, because I honestly have no clue really.
Well its heroes united. Its not a generic under developed source. I may have over exaggerated a bit but yeah lmao. And i guess ill have to try that
That's exactly what Heroes United is, as apparent by the fact that it has "hundreds of verbs".
mob/proc/UpdateGrid()
while(src.client)
src<<output(null, "MainStats")
if(src.pl<0) src.pl=0
if(src.IfTrain==1) src.MulTag=" (x[src.TrainingMultiplier] HBTC Level Multiplier)";src.HBTag=" (+[FullNum(src.TrainingLevels)] HBTC Levels)"
if(src.LevelStore || src.LevelBankStore) src.LvlTag=" (+[FullNum(src.LevelStore+src.LevelBankStore)] Levels)"
if(src.PlStore || src.PlBankStore) src.PlTag=" (+[FullNum(src.PlStore+src.PlBankStore)] Powerlevel)"
if(src.KiStore || src.KiBankStore) src.KiTag=" (+[FullNum(src.KiStore+src.KiBankStore)] Ki)"
if(src.KiDefStore || src.KiDefBankStore) src.KiDefTag=" (+[FullNum(src.KiDefStore+src.KiDefBankStore)] Ki Defense)"
if(src.StrStore || src.StrBankStore) src.StrTag=" (+[FullNum(src.StrStore+src.StrBankStore)] Strength)"
if(src.DefStore || src.DefBankStore) src.DefTag=" (+[FullNum(src.DefStore+src.DefBankStore)] Defense)"
//var/SkillTag="";if(src.SkillStore>0 || src.SkillBankStore>0) SkillTag=" (-[FullNum(src.SkillStore+src.SkillBankStore)] Skill Points)"
if(src.IfTrain==1)
src<<output("[HBTag]/[MulTag]","MainStats")
src<<output("Level: [FullNum(src.level)][LvlTag]","MainStats")
src<<output("PvE Level: [FullNum(src.PVPlvl)]","MainStats")
src<<output("Alignment Points: [FullNum(src.varAlign)]","MainStats")
src<<output("Fatigue: [usr.fatigue]%","MainStats")
src<<output("","MainStats")
src<<output("Powerlevel: [FullNum(src.pl)] / [FullNum(src.mpl)][PlTag]","MainStats")
src<<output("Ki: [FullNum(src.ki)] / [FullNum(src.maxki)][KiTag]","MainStats")
src<<output("Ki Defense: [FullNum(src.kidef)][KiDefTag]","MainStats")
src<<output("Strength: [FullNum(src.str)][StrTag]","MainStats")
src<<output("Defense: [FullNum(src.def)][DefTag]","MainStats")
src<<output("","MainStats")
src<<output("Block Gauge: [FullNum(src.BlockGauge)] / [FullNum(src.TotalBlockGauge)]","MainStats")
src<<output("Max Combo: [FullNum(src.combos)] Hits","MainStats")
src<<output("Z Points: [FullNum(src.ZPoints)]","MainStats")
src<<output("Stat Points: [FullNum(src.statpoints)]","MainStats")
src<<output("Skill Points: [FullNum(src.skillpoints)]","MainStats")
src<<output("Alignment: [src.alignment]% Good","MainStats")
src<<output("Location: [src.x], [src.y], [src.z]","MainStats")
src<<output("Ki Percentage: [src.kipercentage]% : [FullNum(round((usr.ki*(usr.kipercentage/100))),0)] ki","MainStats")
src<<output("Earth Wish: [src.wishwait] Minute Wait","MainStats")
src<<output("Namek Wish: [src.nwishwait] Minute Wait","MainStats")
src<<output("Black Star: [src.bwishwait] Minute Wait","MainStats")
if(src.HasPet==1)
for(Pet in src.PetList)
if(Pet.pl<0) Pet.pl=0
var/LvllTag="";if(Pet.LevelStore>0) LvllTag=" (+[FullNum(Pet.LevelStore)] Levels)"
var/PllTag="";if(Pet.PlStore>0) PllTag=" (+[FullNum(Pet.PlStore)] Powerlevel)"
var/KiiTag="";if(Pet.KiStore>0) KiiTag=" (+[FullNum(Pet.KiStore)] Ki)"
var/KiDeffTag="";if(Pet.KiDefStore>0) KiDeffTag=" (+[FullNum(Pet.KiDefStore)] Ki Defense)"
var/StrrTag="";if(Pet.StrStore>0) StrrTag=" (+[FullNum(Pet.StrStore)] Strength)"
var/DeffTag="";if(Pet.DefStore>0) DeffTag=" (+[FullNum(Pet.DefStore)] Defense)"
src<<output("Pets Level: [FullNum(Pet.level)][LvllTag]","MainStats")
src<<output("Pets Powerlevel: [FullNum(Pet.pl)] / [FullNum(Pet.mpl)][PllTag]","MainStats")
src<<output("Pets Ki: [FullNum(Pet.ki)] / [FullNum(Pet.maxki)][KiiTag]","MainStats")
src<<output("Pets Ki Defense: [FullNum(Pet.kidef)][KiDeffTag]","MainStats")
src<<output("Pets Strength: [FullNum(Pet.str)][StrrTag]","MainStats")
src<<output("Pets Defense: [FullNum(Pet.def)][DeffTag]","MainStats")
src<<output("Pets Stat Points: [FullNum(Pet.statpoints)]","MainStats")
src<<output("Pets Skill Points: [FullNum(Pet.skillpoints)]","MainStats")
sleep(20)

Well maybe im outputting to much into one custom interface window in the time span of 2 seconds. It causes the same amount of lag the statpanel would but i tried something different and didnt receive different results