[Qt-interest] Overhead considerations: QObject::startTimer(), QTimer, QBasicTimer
Thiago Macieira
thiago at kde.org
Tue Sep 13 14:49:37 CEST 2011
On Tuesday, 13 de September de 2011 17:24:04 Pritam Ghanghas wrote:
> Hi All,
>
> I need to use a lot of timers in my application. There are three
> approaches to timer in qt. I looked at documentation and couldn't
> anything that compares their performance or overhead figures.
All three are the same. The difference is the actual object that you're
creating.
QObject::startTimer operates on your existing QObject. There's no extra
overhead.
QBasicTimer also operates on your existing QObject, but it's an extra class
that you have to keep around.
QTimer is a QObject of its own and therefore it operates on itself. It also
communicates via signals, which have a small overhead too.
> QObject::startTimer(), QBasicTimer look very similar in functionality.
> QTimer is easy and neat to use but comes with QObject overhead. I was
> wondering "how much is this overhead? and are there other overheads to
> using QTimer instead of the other two?"
One QObject costs approximately 100 bytes of memory. The overhead of a signal-
slot delivery is around 3 function calls. So unless you're using hundreds of
those or you're in a time-critical section, QTimer is very much acceptable.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110913/5f952f07/attachment.bin
More information about the Qt-interest-old
mailing list