Sunday, December 27, 2009

ViruZ update 5

So, I added threading. The array is split into n parts, so that then n threads can get to work drawing. I'm using a CRITICAL_SECTION to keep cairo okay, since it does not support threads.
Well, since my viruses have a rather small logic (they bounce around), that didn't really pay off for the effort.

I have to make something more efficient, such as creating n rectangles or something and draw on them without the need of a CRITICAL_SECTION I guess, but drawing the viruses doesn't really seem to be the bottleneck.
Drawing them in one thread I get 150-200FPS, in two (I have a dual-core without Hyper-Threading) 170-240FPS and not drawing viruses at all (so just background & FPS-text) 240-430FPS.
The former two are again 100 viruses and I am still drawing the whole screen each frame.

The Thread-class I made is pretty hacky; I think I'm going to take it out again. I'll try how well it performs when I add this separate rectangle-thing and decide upon that. If I get a boost of about 100FPS or more I'll fix the class up, if not I'll remove that feature.

No comments: