[Ktechlab-devel] the timer cuestion

santiago gonzalez santigoro at gmail.com
Fri Oct 2 01:53:38 UTC 2009


I still don't understand the timer cuestion, qtimer is suposed to call
simulator::step() every 1 ms and then a number of calculated steps are
"looped" to reach the non-linear rate (1e4) and logic rate (1e6).

But when i drag&drop an ecclock-input to the circuit it should go at 1 Hz,
but i goes at 0.25 Hz.. it takes 4S for a complete cicle... in diferent PCs
i have diferents timings.. not big diferences.. may be +- 10%.... but 4S for
an 1 Hz ecclock-input is a very big error.

I had a look to qtimer at trolltech docs and it doesn't look a very accurate
thing:
"Note that QTimer's accuracy depends on the underlying operating system and
hardware. Most platforms support an accuracy of 20ms; some provide more..."

...An accuracy of 20ms !!!!!!

http://doc.trolltech.com/3.3/qtimer.html

I think something should be done to improve this.
I have no idea, but looks like C++ doesn't have high-resolution timers...
but what about some POSIX functions?, for example gethrtime() looks
interesting: it gives the nunber of nanosecods since last boot:

http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=332

With a granularity of nanoseconds is possible to do something accurate.

Is possible there are some posix interfaces in some C or C++ library... i
have no idea, but perhaps there are some better solution than using qtimer.

Just a thought...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/ktechlab-devel/attachments/20091002/14914362/attachment.html>


More information about the Ktechlab-devel mailing list