diff options
author | Wolf Bergenheim <ext-wolf.2.bergenheim@nokia.com> | 2010-09-09 10:12:20 +0300 |
---|---|---|
committer | Wolf Bergenheim <ext-wolf.2.bergenheim@nokia.com> | 2010-09-09 10:12:20 +0300 |
commit | 6290bd4353974745f46e2711947d063503f29323 (patch) | |
tree | 78b92ef53140ea0e2c0eafb22c4f302102590b03 /resourceqt-client | |
parent | cd3f7b97ddced403fe2d6eb9091a8903ea186128 (diff) | |
download | libresourceqt-6290bd4353974745f46e2711947d063503f29323.tar.gz |
Changed timer to return ms as a long int
Diffstat (limited to 'resourceqt-client')
-rw-r--r-- | resourceqt-client/client.cpp | 24 | ||||
-rw-r--r-- | resourceqt-client/resourceqt-client.pro | 3 | ||||
-rw-r--r-- | resourceqt-client/time-stat.c | 7 | ||||
-rw-r--r-- | resourceqt-client/time-stat.h | 2 |
4 files changed, 19 insertions, 17 deletions
diff --git a/resourceqt-client/client.cpp b/resourceqt-client/client.cpp index daf0486..7f999b2 100644 --- a/resourceqt-client/client.cpp +++ b/resourceqt-client/client.cpp @@ -185,9 +185,9 @@ void Client::showResources(const QList<Resource*> &resList) void Client::resourceAcquiredHandler(const QList<ResourceType>& /*grantedResList*/) { - double ms = stop_timer(); - if( ms > 0.0 ) { - output << "Operation took " << (quint32)ms << "ms"; + long int ms = stop_timer(); + if( ms > 0 ) { + output << "Operation took " << ms << "ms"; } QList<Resource*> list = resourceSet->resources(); @@ -203,9 +203,9 @@ void Client::resourceAcquiredHandler(const QList<ResourceType>& /*grantedResList void Client::resourceDeniedHandler() { - double ms = stop_timer(); - if( ms > 0.0 ) { - output << "Operation took " << (quint32)ms << "ms"; + long int ms = stop_timer(); + if( ms > 0 ) { + output << "Operation took " << ms << "ms"; } output << "\nManager denies access to resources!" << endl; @@ -214,9 +214,9 @@ void Client::resourceDeniedHandler() void Client::resourceLostHandler() { - double ms = stop_timer(); - if( ms > 0.0 ) { - output << "Operation took " << (quint32)ms << "ms"; + long int ms = stop_timer(); + if( ms > 0 ) { + output << "Operation took " << ms << "ms"; } output << "\nLost resources from manager!" << endl; @@ -225,9 +225,9 @@ void Client::resourceLostHandler() void Client::resourceReleasedHandler() { - double ms = stop_timer(); - if( ms > 0.0 ) { - output << "Operation took " << (quint32)ms << "ms"; + long int ms = stop_timer(); + if( ms > 0 ) { + output << "Operation took " << ms << "ms"; } output << "\nAll resources released" << endl; diff --git a/resourceqt-client/resourceqt-client.pro b/resourceqt-client/resourceqt-client.pro index bd2c178..ce378c6 100644 --- a/resourceqt-client/resourceqt-client.pro +++ b/resourceqt-client/resourceqt-client.pro @@ -11,7 +11,8 @@ CONFIG -= app_bundle INCLUDEPATH += $${LIBRESOURCEINC} QMAKE_CXXFLAGS += -Wall -LIBS += -L$${LIBRESOURCEQT}/build -lresourceqt -L$${LIBDBUSQEVENTLOOP}/build -ldbus-qeventloop +QMAKE_CFLAGS += -std=c99 -D_POSIX_C_SOURCE=199309L +LIBS += -L$${LIBRESOURCEQT}/build -lresourceqt -L$${LIBDBUSQEVENTLOOP}/build -ldbus-qeventloop -lm -lrt # Input HEADERS = client.h commandlineparser.h time-stat.h diff --git a/resourceqt-client/time-stat.c b/resourceqt-client/time-stat.c index 6fb4fdc..c18daa5 100644 --- a/resourceqt-client/time-stat.c +++ b/resourceqt-client/time-stat.c @@ -1,6 +1,7 @@ +#include <math.h> #include "time-stat.h" -static struct timespec start_time = {0,0}; +static struct timespec start_time; int start_timer(void) { @@ -13,7 +14,7 @@ int start_timer(void) return 0; } -double stop_timer(void) +long int stop_timer(void) { struct timespec end_time; int r; @@ -28,6 +29,6 @@ double stop_timer(void) start_time.tv_sec = 0; start_time.tv_nsec = 0; - return milliseconds; + return lround(milliseconds); } diff --git a/resourceqt-client/time-stat.h b/resourceqt-client/time-stat.h index 0bd5eaf..e32a4cb 100644 --- a/resourceqt-client/time-stat.h +++ b/resourceqt-client/time-stat.h @@ -7,7 +7,7 @@ extern "C" { #endif int start_timer(void); -double stop_timer(void); +long int stop_timer(void); #ifdef __cplusplus } #endif |