ID:31996
 
Before you start, make sure that somewhere in your code you have

#define DEBUG
written.



99% of byond developers are not aware of the tools included with byond for finding out how to catch troublesome procs that are running up all your CPU time! The most important thing that a BYOND coder should do to manage his game is the following:
create a new folder in the same directory as your game's host file and name it cfg. Inside that folder make a new text file called admin.txt

/cfg/admin.txt

Now edit admin.txt and add a line like this

Masterdan role=coder

nothing more to it.
to add more admins

Bustercannon role=eyecandy

save this file like that and any admins you've defined (use their keys) will when joining the server (of course you have to shutdown fully and bring back up the server if you change this file) will be able to do 2 things.

Profile World
Reboot World

Both within Dreamseeker. Now reboot world isnt the point of this tutorial, profile world is. Using Profile world youll get something similar to this CPU Profile of Naruto GOA

Note a few things, /client/Topic is the proc for refreshing the cpu profiler, so the fact that me refreshing the profiler 16 times is our number one lag inducer at 66 people online is a good sign. Topic is also used for other things, but its fairly complicated and if you use it, you should know how it works. Anywho youll be using the Self CPU time mostly for your analysis. Currently our Fire proc uses up the most cpu, 15 calls to fire were used and it is a graphical effect that creates and deletes objects. So nothing is out of the ordinary here. This profile is Total,so its a cumulative effect of roughly 5 minutes of procs running. If you have a proc that has a very high self CPU time and a relatively low amount of calls then you need to worry. Code like that usually is what causes lag spikes which are a games worst enemy. CPU usage isnt a problem when the computer can handle it all, but a quick surge of cpu usage is a problem. You can remedy alot of heavy workload tasks by slipping calls to sleep(-1) and using sleep(positivenumber) more often. Look up sleep for more on that in the DM references. Anyway dont pay much thought to realtime as its the literal time spent on a proc which really doesnt mean anything to you. Total cpu time tells you the cpu used up not just by the proc but by the proc and every other proc IT calls. So sometimes when you have a proc with a very high total cpu but a high amount of calls you want to look for a proc thats got a high total cpu time to find out what has been calling the offending proc so darn often. Also the average button can be used to find the cpu used on 1 iteration of a proc, useful when weeding out lag spikes as a proc that uses up 1.00 of self cpu time on average will really beat the crap out of the server.

Cheers!

PS: One note i should make, when contesting wether or not 2 games are from the same source, submitting both cpu profiles to an impartial judge is a good way of determining if the code is in fact the same. However the thin disguise of changing the names of procs would make this more difficult to compare, still you can read a great deal into how a games code is done simply by looking at this. a Querky detail thats similar between 2 sources such as maybe GOA's AOExk2 [which is Dan gibberish for my AreaOfEffect x(dont effect the caster) k2(specified range and a sequel to the regular AOExk proc) is definete proof of ripping! GOA isnt afraid of its code of course, so our cpu profile is publically posted now :D
Doesn't define debug very slightly slow down the overal BYOND program? So once you've fixed all the foreseeable problems and want to release your game to be played by the public, you should probably remove the define DEBUG bit.
Also: judging if two games were made from the same source by comparing CPU usage isn't a good way at all.

I don't know if there would ever be a good way, other than just checking the game out and looking for obvious similarities, but comparing CPU usage isn't a good way. CPU usage can vary wildly- depending on things like the amount of players, and the power of the processor!

Even if they did have a similar CPU "profile", that wouldn't prove anything. I could make a game that has nearly indentical CPU usage as Dantom's a step BYOND, but they'd clearly not be the same game.
No. The only thing that happens with debug is that it emits symbols for debugging - the slowdown will be *extremely* miniscule. The information is used to display information when say, a proc causes a runtime error - it will display stack, line information and such.

Elation wrote:
Doesn't define debug very slightly slow down the overal BYOND program? So once you've fixed all the foreseeable problems and want to release your game to be played by the public, you should probably remove the define DEBUG bit.

Elation wrote:
Also: judging if two games were made from the same source by comparing CPU usage isn't a good way at all.

I don't know if there would ever be a good way, other than just checking the game out and looking for obvious similarities, but comparing CPU usage isn't a good way. CPU usage can vary wildly- depending on things like the amount of players, and the power of the processor!

Even if they did have a similar CPU "profile", that wouldn't prove anything. I could make a game that has nearly indentical CPU usage as Dantom's a step BYOND, but they'd clearly not be the same game.

You really misunderstand, being able to look at the proc NAMES mostly is how you would compare two games' CPU profile
Lag and CPU usage are two very different things. In a well programed game the CPU shouldn't even get near 50, unless you're pushing the limits of the BYOND suite.

Lag, AKA latency, is caused by poor or bogged down internet connections, like mine *cries*. Admittedly, if you're computer is freaking out because of the strain your game is putting on it, it may cause a form of lag.

Although, Profile World is a great way to look for things that aren't doing what they should. Processes that are being run too many times, for example.

Also, I can't see the Profile you mentioned...
The shortcut for profile world, in case you can not see it, is CTRL + P.. but if you're a player and not defined in the admin list as Masterdan mentioned, or running the game, it won't work.