reduce cpu load
authorClaus Gittinger <cg@exept.de>
Tue, 12 Jun 2001 11:57:08 +0200
changeset 3023 abe1daf204c3
parent 3022 1063cadd13f7
child 3024 51e109cb8ae0
reduce cpu load
ProcessMonitor.st
--- a/ProcessMonitor.st	Thu May 24 16:50:39 2001 +0200
+++ b/ProcessMonitor.st	Tue Jun 12 11:57:08 2001 +0200
@@ -155,7 +155,9 @@
     |oldList list line dIndex interrupted contextCount 
      aProcess nm st n found running sel space oldSelection
      newSelection numHeaderLines nameLength index
-     con c totalStack sender id gId r skipping|
+     con c totalStack sender id gId r skipping startTime endTime deltaT|
+
+    startTime := AbsoluteTime now.
 
     numHeaderLines := 2.
     space := Character space.
@@ -420,6 +422,24 @@
         "/ without the flush, the output may look ugly (delayed)
         listView flush
     ].
+
+    endTime := AbsoluteTime now.
+    deltaT := (endTime millisecondDeltaFrom:startTime) / 1000.0.
+    "/ Transcript show:deltaT; show:' ' ; showCR:(updateDelay / 10.0).
+    deltaT > (updateDelay / 5) ifTrue:[
+        "/ the update took longer than 20% - make delay longer, to reduce cpu load.
+        updateDelay := updateDelay * 2.
+        "/ Transcript show:'+++ '; showCR:updateDelay.
+    ] ifFalse:[
+        updateDelay > 0.5 ifTrue:[
+            deltaT < (updateDelay / 20) ifTrue:[
+                "/ the update took less than 5% - make delay smaller for better animation.
+                updateDelay := (updateDelay / 2) max:0.5.
+                "/ Transcript show:'--- ';showCR:updateDelay.
+            ].
+        ].
+    ].
+
     updateBlock notNil ifTrue:[
         Processor removeTimedBlock:updateBlock.
         Processor addTimedBlock:updateBlock afterSeconds:updateDelay
@@ -743,5 +763,5 @@
 !ProcessMonitor class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/ProcessMonitor.st,v 1.75 2001-04-10 14:26:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/ProcessMonitor.st,v 1.76 2001-06-12 09:57:08 cg Exp $'
 ! !