diff options
author | Daniel Burrows <dburrows@debian.org> | 2009-03-21 08:42:47 -0700 |
---|---|---|
committer | Daniel Burrows <dburrows@debian.org> | 2009-03-21 08:42:47 -0700 |
commit | 4d6973ebe27bebb2c9071d29c4ab0508a3ae16f7 (patch) | |
tree | 8476f4004d545d12e6d14304df95f58fbac5eba8 /tools/resolver-visualize | |
parent | cb145a029546f5317a0b5b3c9a924b2e651f2f98 (diff) | |
download | aptitude-4d6973ebe27bebb2c9071d29c4ab0508a3ae16f7.tar.gz |
Fix the logic that decides when to update the progress bar.
Before, we were updating it on every line. With this change, log files
are still slow to load, but they load in a somewhat reasonable amount
of time.
Diffstat (limited to 'tools/resolver-visualize')
-rwxr-xr-x | tools/resolver-visualize/Main.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/resolver-visualize/Main.hs b/tools/resolver-visualize/Main.hs index 07082791..23f6ab79 100755 --- a/tools/resolver-visualize/Main.hs +++ b/tools/resolver-visualize/Main.hs @@ -291,19 +291,19 @@ load fn = do loadedFile <- liftIO $ do (xml, win) <- loadLoadingProgressXML labelSetText title ("Loading " ++ fn ++ "...") widgetShow win h <- openFile fn ReadMode - currTime <- getClockTime - lastTime <- newIORef currTime + lastTime <- newIORef Nothing log <- loadLogFile h fn (showProgress progressBar lastTime) return log (xml, ctx) <- newMainWindow liftIO $ runVis (setLog loadedFile) ctx liftIO $ xmlGetWidget xml castToWindow "main_window" >>= widgetShow return () - where showProgress :: ProgressBar -> IORef ClockTime -> Integer -> Integer -> IO () + where showProgress :: ProgressBar -> IORef (Maybe ClockTime) -> Integer -> Integer -> IO () showProgress pb lastTime cur max = do oldf <- progressBarGetFraction pb currTime <- getClockTime last <- readIORef lastTime + writeIORef lastTime (Just currTime) let updateInterval = TimeDiff { tdYear = 0, tdMonth = 0, tdDay = 0, @@ -313,7 +313,9 @@ load fn = do loadedFile <- liftIO $ do (xml, win) <- loadLoadingProgressXML tdPicosec = milliToPicoseconds 100 } newf = if max == 0 then 0 else ((fromInteger cur) / (fromInteger max)) bigUpdate = oldf - newf >= 0.01 - longUpdate = diffClockTimes currTime last >= updateInterval + longUpdate = case last of + Nothing -> True + Just time -> diffClockTimes currTime time >= updateInterval shouldUpdate = bigUpdate || longUpdate when shouldUpdate (do progressBarSetFraction pb newf mainContextIteration mainContextDefault False |