[svn] r6236 - trunk/tools/dstat

packagers at lists.rpmforge.net packagers at lists.rpmforge.net
Wed Mar 26 11:58:51 CET 2008


Author: dag
Date: 2008-03-26 10:58:50 +0000 (Wed, 26 Mar 2008)
New Revision: 6236

Modified:
   trunk/tools/dstat/dstat
Log:
Small improvements in main loop.

Modified: trunk/tools/dstat/dstat
===================================================================
--- trunk/tools/dstat/dstat	2008-03-25 15:26:20 UTC (rev 6235)
+++ trunk/tools/dstat/dstat	2008-03-26 10:58:50 UTC (rev 6236)
@@ -1940,22 +1940,22 @@
     scheduler = sched.scheduler(time.time, time.sleep)
     inittime = time.time()
 
-    update = -1
+    update = 0
     missed = 0
 
     ### Let the games begin
     while update <= op.delay * op.count or op.count == -1:
+        scheduler.enterabs(inittime + update, 1, perform, (update,))
+        scheduler.run()
         update = update + interval
-        scheduler.enterabs(inittime + update, 1, perform, ())
-        scheduler.run()
 
     if op.update:
         sys.stdout.write('\n')
 
-def perform():
+def perform(update):
         global totlist, oldvislist, vislist, showheader, rows, cols
         global tick, totaltime, starttime
-        global loop, step, update, missed
+        global loop, step, missed
 
         starttime = time.time()
 
@@ -1972,7 +1972,7 @@
 
         ### FIXME: This is temporary functionality, we should do this better
         ### If it takes longer than 500ms, than warn !
-        if starttime - inittime - update > 1:
+        if loop != 0 and starttime - inittime - update > 1:
             missed = missed + 1
             return 0
 
@@ -2014,7 +2014,7 @@
         if op.update:
             if step == 1 and update != 0:
                 sys.stdout.write('\n' + ansi['reset'] + ansi['clearline'] + ansi['save'])
-            else:
+            elif loop != 0:
                 sys.stdout.write(ansi['restore'])
 
         ### Display header




More information about the commits mailing list