Unsolved How can I get a difference between two DateTime intervals in micro and nano seconds?
-
@srikanth
Im not sure nano is an option unless high precision timer is available.You can google on ways to time functions etc in c++
Sounds like you want something like that
http://stackoverflow.com/questions/15092504/how-to-time-a-function-in-milliseconds-without-boosttimerThere are also native windows functions etc but i do not know what task or requirements you have.
There are a lot on google.
-
boost chrono is an option, I don't think it needs C++11.
Do you need to get the difference between 2 timers (so you have to get the current time) or is it the difference of some static data-points you have? in the second case you can handle it quite simply manually
-
You can use
#include <QElapsedTimer>
its has the function
qint64 QElapsedTimer::nsecsElapsed() const
that is nano seconds since last started.
Available since Qt 4.7. -
That's what I would have proposed except his environment uses Qt 4.3.2
-
@SGaist
Oh, I missed that, sorry.
For some reason all I thought was "pre Qt5.0 so it fits" . -
Hi
He is trying the boost chrono as @VRonin suggest but
im not sure building it with VS 2005 is great joy. ? :) -
@mrjj The current release uses C++11 but boost version 1.47.0 does not. I also think boost::chrono and std::chrono are the same thing
-
@VRonin
Ah and such old version might have makefile for Vs 2005 included.
We cross fingers :=) -
can i use chrono in VS 2005 , am unable to get nanoseconds is there anyway to get nanoseconds in vs 2005 & Qt 4.3.2
-
@srikanth As @VRonin said you can use Boost 1.47.0 (boost::chrono: https://theboostcpplibraries.com/boost.chrono).
-
@jsulm i downloaded the boost.zip file from this link
[http://www.boost.org/users/history/version_1_63_0.html]unzip them and then add something like INCLUDEPATH += C:/boost/boost_1_63_0/ to my pro file , if i run this code then it is getting error like this "fatal error LNK1104: cannot open file 'libboost_chrono-vc80-mt-gd-1_63.lib' " so what can i do now ? to get this lib file .
-
@srikanth
Try the 1.47.0 one.
1_63 might be too new for VS 2005. -
@srikanth You need to link to the library mentioned in the error message:
LIBS += -LPATH_TO_BOOST_LIBS -lboost_chrono-vc80-mt-gd-1_63
-
QueryPerformanceCounter is giving microseconds
but not in exactly
i have one doubt in this
please check my code once
https://paste.ofcode.org/gg6d6ESDmJHDkxxQmkUkbN -
It depends on the source. You have all the explanations here.