[Qt-interest] QFile private member

Pete Christensen qt at graffiti.graceland.ca
Wed Feb 11 04:11:18 CET 2009


> Except in this case, the cost of constructing the QFile object is likely
> to be significant if you're using it multiple times. A once-off usage is
> fine for constructing it on the fly, otherwise, you can just extract the
> filename back out of the instantiated QFile object sitting in your
> pointer. Cost vs Benefit is worth keeping in mind when designing your
> code as much as your interface. Will this be used on mobile (aka 300MHz
> device)? Will the memory overhead be worth the reduced instruction count
> (32M or 64M total memory is common in the mobile arena)?  That said,
> ease of readability should always be factored in too :)
> 

Good advice, thanks. I'll do that though my target platform is a desktop 
workstation. I'm just reading and parsing a log file. Basically 
re-building tail so I can parse stuff out of the log file as data 
appends to it. I'll need to re-open the file and stream periodically 
when the log rolls over, though.

As an aside, the performance of my little doo-dad seems pretty good even 
though I read somewhere in my travels that QTextStream.readLine() wasn't 
exactly optimized. I have a 22MB log file that cat can pump out into my 
terminal in 1:20. QTextStream in my QThread takes 1:35. I doubt that's a 
very scientific test, but I was impressed.

I had a pretty productive day, in the end, thanks to you guys, plus I 
got to flame-war with a dick-head. Bonus! Also, I've downloaded the book 
you mentioned, and I'll give it a go over the next while. I went through 
Appendix D of the TrollTech Qt GUI book pretty carefully over the past 
few days, but a lot of stuff hasn't sunk in yet :)

Not sure what happened to the subject. I replaced it.



More information about the Qt-interest-old mailing list