Thursday, January 28, 2010

Detour Performance

I've been ill the past week, and I thought I'd use the time between naps and sneezing to catch up with things I think that needs to be done, but have been to numbing to do unless you are somehow light headed. Profiling while trying to get new exiting features finsihed is one of those tasks.

I have not checked the performance of Detour in quite a while. New features have been poured in, meshes have now detail, arrays changed to linked lists, and what not.

I added a simple test case code which loads a map, sample, generates the mesh and runs batch of pathfind requests. The results were not too devastating, but I sense that there is room for improvement later on.

The menu to launch the tests are behind a magic button, since I have not distributed all the meshes I use, the code is a bit hackish, etc.

The pathfind request in the title image takes about 0.111 ms. That is complete with querying two nearest polygons at the start and end locations, A*, and string pulling the final result. The mesh consists of about 710 polygons, and as you can see the A* touches almost all the polys there.

A* seems to be the bottle neck, I'm pretty sure there are room for improvement in there. Once I get into optimization mood, I think I need to find better profiling tools, simple perf timer query does not seem to be accurate enough (I'm using the preferred unix way to get the timer value).

The above picture shows how much path you can get for 0.051 ms (the start it at right near the text, the end is at left where the yellow line finally ends). Depending on your per frame budget that can be a little or a lot. I'm not panicking yet.