PDA

View Full Version : high processor waste...



kernel_panic
7th June 2008, 17:11
Here's the code: http://www.file-upload.net/download-900427/matrix.zip.html
The Problem is the high processor waste. I think i implemented the QThread wrong. Thanks for help!

marcel
7th June 2008, 18:24
You're scheduling way too much paint events... every 100ms and every 20ms => 60 paint events/second.
and using the threads matrix streams that way is not really safe.
the paint event is asynvhronous and you read there the streams from the worker... but the in the same time the thread could update the streams.

also, what is the point of that mutex in the two update methods? I don't really see its use.

one last thing: you're creating the matrix streams in the thread's constructor, therefore they will live in the main thread. I don't think that causes any damage in your case...

kernel_panic
7th June 2008, 19:22
ok.. so the problem is the painting. i think i have to use opengl? or can i speed up the Qt paint engine?

fanat9
9th June 2008, 18:28
Just wanna mention - you can use profiler to find possible bottlenecks. Or in your case prove its really painting.
http://wiki.qtcentre.org/index.php?title=Profiling_with_GNU_gprof

spud
9th June 2008, 23:12
Yes, it's probably the renderering that's your bottleneck. OpenGL would be faster if you want to keep the frame rate, but you should cache the font as display lists (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=43) instead of rendering every single letter(caching the font is probably a good idea even if you decide against opengl). Also, your usage of threads doesn't seem justified since you are controlling the animation with timers anyway.