Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
d01a189d8f

+ 15 - 0
panda/src/express/config_express.cxx

@@ -49,6 +49,21 @@ get_leak_memory() {
 
 //const bool track_memory_usage = config_express.GetBool("track-memory-usage", false);
 
+// Set this to false to avoid using the high-precision clock, even if
+// it is available.
+bool
+get_use_high_res_clock() {
+  static bool got_use_high_res_clock = false;
+  static bool use_high_res_clock;
+
+  if (!got_use_high_res_clock) {
+    use_high_res_clock = config_express.GetBool("use-high-res-clock", true);
+    got_use_high_res_clock = true;
+  }
+  
+  return use_high_res_clock;
+}
+
 const int patchfile_window_size =
 	config_express.GetInt("patchfile-window-size", 16);
 

+ 1 - 0
panda/src/express/config_express.h

@@ -21,6 +21,7 @@ NotifyCategoryDecl(express, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS);
 //extern EXPCL_PANDAEXPRESS const bool track_memory_usage;
 
 bool get_leak_memory();
+bool get_use_high_res_clock();
 
 extern const int patchfile_window_size;
 extern const int patchfile_increment_size;

+ 16 - 11
panda/src/express/trueClock.cxx

@@ -37,14 +37,6 @@ get_real_time() const {
     LARGE_INTEGER count;
     QueryPerformanceCounter(&count);
 
-    if (_init_count > count.QuadPart)
-      _init_count = count.QuadPart;
-
-    if (_frequency < 0) {
-      express_cat.error()
-	<< "TrueClock::get_real_time() - frequency is negative!" << endl;
-      QueryPerformanceFrequency((LARGE_INTEGER *)&_frequency);
-    }
     return (double)(count.QuadPart - _init_count) / (double)_frequency;
 
   } else {
@@ -57,12 +49,25 @@ get_real_time() const {
 
 TrueClock::
 TrueClock() {
-  _has_high_res = QueryPerformanceFrequency((LARGE_INTEGER *)&_frequency);
+  _has_high_res = false;
+  if (get_use_high_res_clock()) {
+    _has_high_res = QueryPerformanceFrequency((LARGE_INTEGER *)&_frequency);
+  }
 
   if (_has_high_res) {
-    QueryPerformanceCounter((LARGE_INTEGER *)&_init_count);
+    LARGE_INTEGER count;
+    QueryPerformanceCounter(&count);
+    _init_count = count.QuadPart;
 
-  } else {
+    if (_frequency <= 0) {
+      express_cat.error()
+	<< "TrueClock::get_real_time() - frequency is negative!" << endl;
+      _has_high_res = false;
+    }
+
+  }
+
+  if (!_has_high_res) {
     express_cat.warning()
       << "No high resolution clock available." << endl;