View Single Post
Old 01-18-2005, 04:29 PM   #5 (permalink)
Rawb
Crazy
 
Location: Salt Town, UT
There are two things I go to when I start with something like that:

1. strace (or truss, or something else, depending on which os you are running on), it will give you a real-time list of every system call that process is making. It is pretty intensive, so it takes a bit, but it will let you know if you are doing a flood of reads or writes or malloc's that are killing your system. I've used it to debug a few things.

2. vmstat (or something else, depending on what system you are running on), this will let you know what part of your system appears to be the bottleneck, it will show you if it is swapping, or if you are running a ton of I/O and your disk can't keep up.

If it's not one of those, or vmstat is showing that your CPU is spiking, odds are that you have some bad code in there. To figure out what kind of code is killing you, you need a profiler, gprof is one I have tried, but it has been ages, so I can't remeber how to use it, I can just tell you to give it a shot. If you are really looking to run some optimizations (hopefully not needed for a text-based game), you can also run valgrind to see where your cache choke points are.

Just remember, try and optimize the largest thing and only the largest thing, one at a time and just keep on moving down the list until you get it good enough.
Rawb is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76