[Moved] QdateTime



  • I am trying to convert a C# program that use Datetime class.
    The precision on this class in C# is in tick - equivalent to 0.1 micro second .
    Has anybody done some work on Qdatetime to inherit this class and modify the api to be able to handle this precision?
    Is this the best way to start?



  • QDateTime wasn't really written to be extensible, I am afraid, so subclassing QDateTime doesn't sound like a promising approach. You may have to write your own TickDateTime class. Please also notice that not all platforms support such granularity (one reason that QDateTime is based on milliseconds is that that is a granularity that all platforms supported by Qt these days support themselves).



  • [quote author="kalle" date="1286803210"]Please also notice that not all platforms support such granularity (one reason that QDateTime is based on milliseconds is that that is a granularity that all platforms supported by Qt these days support themselves).[/quote]

    I find this limitation a bit surprising. Java introduced the nanoTime() call in JDK 1.5 and claims to try to get the system time in nano seconds (though not fully accurate), there must be some way to do this in Qt. IMHO millis is really quite limited !!!



  • 0.1 microsecond = 1 nanosecond

    clock_gettime gives seconds and nanoseconds, so there is your answer.

    Do you really need that level of accuracy ?



  • In microsecond yes, have run into "0" ms time taken for many methods while measuring performance. nanosecond .. not yet :)

    also isn't 0.001 micro = 1 nano ?



  • In microsecond yes, have run into “0” ms time taken for many methods while measuring performance.
    It means you have no to do with these methods optimization, do you?. Besides you should use appropriate software for profiling instead of using custom non-precise methods.

    0.1 microsecond = 1 nanosecond
    1 microsecond = 10^-6
    1 nanosecond = 10^-9
    0.1 microsecond != 1 nanosecond

    Is this the best way to start?
    I think it is better to use platform-dependent methods when you really need such a precision without any Qt wrapping.



  • [quote author="chetankjain" date="1287026068"]also isn't 0.001 micro = 1 nano ?[/quote]

    Silly me, yes, they are an order of magnitude different, but the question stands: Do you REALLY need that much accuracy ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.