Recommended Posts

I was wondering about how to better debug and profile my games. I use Visual Studio with its debugger and profiler, but there are cases where they are difficult or impractical to use which is why I'm adding various tools to my "engine". A typical example is the debug console which can display explicit Log(message) calls, and their callstacks when messages are clicked. My console also allows arbitrary C# and IronPython statements which is great for debugging and testing. Included in this I also support a command which displays the result of an arbitrary expression on screen. Great for debugging mouse movements, picking etc.

My "engine" also has basic support for profiling subsystems by using something like BeginProfile/EndProfile which creates a treeview-like view when nested. It displays something like the minimum, maximum and average timings over N frames. It can be pretty helpful, but requires alot of manual instrumentation which I'm not entirely happy with. How can I improve this to make it more useful while less intrusive to the code?

What other debug and/or performance tools have you found to improve your development experiences?

Link to post

Share on other sites

My "engine" also has basic support for profiling subsystems by using something like BeginProfile/EndProfile which creates a treeview-like view when nested. It displays something like the minimum, maximum and average timings over N frames. It can be pretty helpful, but requires alot of manual instrumentation which I'm not entirely happy with. How can I improve this to make it more useful while less intrusive to the code?

It is surprisingly easy to write your own in-game sampling profiler. It's really just another thread that periodically pauses and snoops the instruction pointer of the other threads. You can walk the call stack to generate the complete stack. You can also record other data in your own stack-like structures if you want to show additional context besides the raw call stack.

1

Share this post

Link to post

Share on other sites

I'm interested in trying to create my own sampler, but I'm not sure how well that works with .NET and it's JIT compilation..? Also, the best thing would be if I could add a command similar to "prof MyClass.MyMethod" to hook that method and wrap it in BeginProfile/EndProfile calls.

I found a CodeProject article/sample which is supposed to allow modifying code while running. It's samples work, but I'm unable to get it working for my own code.

I keep getting invalid program exceptions when trying to run a modified method, even though I tried to take the contents from an identical method. I gotta wonder if there's a way to do this that actually works. I also gotta wonder why it works in those samples but not in my code... Hmm. Anyway, anyone successfully managed to hook a method in C#?

0

Share this post

Link to post

Share on other sites

This topic is 1441 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.