[Kst] branches/work/kst/portto4/kst

Peter Kümmel syntheticpp at gmx.net
Sun Mar 27 22:33:48 CEST 2011


SVN commit 1226229 by kuemmel:

also compile on FreeBSD, thx to Max Brazhnikov

 M  +1 -1      cmake/src/libkst/CMakeLists.txt  
 M  +25 -16    src/libkst/measuretime.cpp  
 M  +2 -0      src/libkst/measuretime.h  


--- branches/work/kst/portto4/kst/cmake/src/libkst/CMakeLists.txt #1226228:1226229
@@ -2,7 +2,7 @@
 
 kst_files_ignore(stdinsource timezones)
 
-if(WIN32 OR APPLE )
+if(WIN32 OR APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
 	kst_files_ignore(sysinfo psversion)
 else()
 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lrt")
--- branches/work/kst/portto4/kst/src/libkst/measuretime.cpp #1226228:1226229
@@ -64,37 +64,46 @@
 }
 
 
-void MeasureTime::restart()
+double MeasureTime::getTime() const
 {
 #ifdef Q_OS_WIN
+
   LARGE_INTEGER st;
   QueryPerformanceCounter(&st);
-  started = st.QuadPart * frequency;
+  return st.QuadPart * frequency;
+
 #else
-#ifndef Q_OS_MAC
+
+#if defined(Q_OS_MAC)
+  // TODO
+  return 0;
+#else
   timespec t;
+#if defined(CLOCK_PROCESS_CPUTIME_ID)
   clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t);
-  started = 1.0 * t.tv_sec + 1e-9 * t.tv_nsec;  
+#elif defined(CLOCK_PROF)
+  clock_gettime(CLOCK_PROF, &t);
+#else
+  clock_gettime(CLOCK_REALTIME, &t);
 #endif
+  return 1.0 * t.tv_sec + 1e-9 * t.tv_nsec;
 #endif
+
+#endif
+
+}
+
+
+void MeasureTime::restart()
+{
+  started = getTime();
   interval = 0;
 }
 
 
 void MeasureTime::measure()
 {
-  double now = 0;
-#ifdef Q_OS_WIN
-  LARGE_INTEGER st;
-  QueryPerformanceCounter(&st);
-  now = st.QuadPart * frequency;
-#else
-#ifndef Q_OS_MAC  
-  timespec t;
-  clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t);
-  now = 1.0 * t.tv_sec + 1e-9 * t.tv_nsec;
-#endif
-#endif
+  double now = getTime();
   interval += now - started;
   started = now;
 }
--- branches/work/kst/portto4/kst/src/libkst/measuretime.h #1226228:1226229
@@ -46,6 +46,8 @@
 
     /// Increment interval by interval since last call/restart().
     void measure();
+
+    double getTime() const;
 };
 
 #define TIME_IN_SCOPE(x) MeasureTime x(QString("%1 at %2, line %3, time in scope").arg(#x).arg(__FILE__).arg(__LINE__))


More information about the Kst mailing list