[Development] Perf about loading one 240x320 png image

João Abecasis joao at abecasis.name
Sun Sep 30 22:00:14 CEST 2012


Diego Iastrubni wrote:
> My experience is with Qt4... but I do see that QFile was slow for me. I
> needed to parse a simple text file from a real disk (~10mb size, simple
> state machine, no regex, application run several times for disk IO to get
> working thus reducing the impact of HW). My first try was using
> QFile::readLine, and using QString. I then ported it to use ANSI C and char*
> (only for the parsing, the rest of the project was still using Qt4 classes).
>
> This simple refactoring (QFile -> fopen()) changed loading time (on
> windows):
>    file1.txt: 515msec to 230msec
>    file2.txt: 420msec to 155msec
>
> On linux (the same HW, double booting) the Qt QIO classes were not that
> slow, but the standard C functions were also faster.
>
> Is anyone seeing similar things?

There are places where QFile can be optimized. One of them is
continuing with the removal of the QAbstractFileEngine abstraction, as
was done for QFileInfo, QDir and QDirIterator in Qt 4.8. I suppose a
few percentual points on select use cases can be recouped by
optimizing the code itself even after that. Still, at the end of the
day, Qt I/O APIs, as they exist today, will always add overhead over
the native APIs.

The overhead is inherent to the design: Qt wraps low-level native APIs
in another low-level cross-platform API. As the interface mostly
remains at the same level it is wrapping, this means one gets Qt's
"wrapper overhead" at every single native API call. Or mostly so.

Cheers,


João



More information about the Development mailing list