PDA

View Full Version : Implementing a better (faster) logging console



nightghost
3rd February 2010, 14:26
According to my previous post (http://www.qtcentre.org/threads/27446-Reading-lots-of-Data-from-QProcess-without-freezing) I am having problems with a small logging console, that was not fast enough. So I decided to redesign it according to your tips.

I setup a small project in Qt Creator (first time using it ;)) and put it on my github account (http://github.com/eigenghost/qt_logging_console)

Its just a QMainWindow with a start/stop button and a button to enable or disable the highlighting an a small lpm (lines per minute) counter. The Performance is really good (in comparison to my old console). Its not finished, but I feel I am on the right path. If your like look at it and post me your comments (interesting are only two small classes (http://github.com/eigenghost/qt_logging_console/tree/master/src/) - not much to read)

Greetings
nightghost

franz
3rd February 2010, 21:27
It is likely that you will want to be able to log without interrupting the operation too much. You might be interested in queuing the data to be written. Copying a QString is a constant time operation, writing the data to screen probably isn't.

You might want to look into thread safety when you got the basics going and you are happy with the progress.

Reading from stdout/stdin/QProcess is probably safe enough at this point.

Other than that, you can consider using the QtTestLib to test and benchmark your code. This will help you identify the most time intensive operation in your application. You might be able to optimize even more.

Hint: start with the test. Test driven development is really good for your productivity. The stuff I wrote above is untested and I can give no guarantee that it will actually help improve your code. A proper unit test will, though.