From 76aa0a0cd8446dccd580b431ecc0883c7bd817e3 Mon Sep 17 00:00:00 2001 From: Adam Lerer Date: Fri, 6 Feb 2015 00:46:01 -0500 Subject: Clear correct number of progress bar spaces. --- init.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 6af7c20..b29bc13 100644 --- a/init.lua +++ b/init.lua @@ -231,6 +231,7 @@ end do local barDone = true local previous = -1 + local tm = '' local timer local times local indices @@ -247,6 +248,7 @@ do if (barDone and ((previous == -1) or (percent < previous))) then barDone = false previous = -1 + tm = '' timer = torch.Timer() times = {timer:time().real} indices = {current} @@ -266,8 +268,8 @@ do end glob.io.write('] ') -- time stats - for i=1,50 do glob.io.write(' ') end - for i=1,50 do glob.io.write('\b') end + for i=1,#tm do glob.io.write(' ') end + for i=1,#tm do glob.io.write('\b') end local elapsed = timer:time().real local step = (elapsed-times[1]) / (current-indices[1]) if current==indices[1] then step = 0 end @@ -278,7 +280,7 @@ do indices = table.splice(indices) times = table.splice(times) end - local tm = 'ETA: ' .. formatTime(remaining) .. ' | Step: ' .. formatTime(step) + tm = 'ETA: ' .. formatTime(remaining) .. ' | Step: ' .. formatTime(step) glob.io.write(tm) -- go back to center of bar, and print progress for i=1,47+#tm do glob.io.write('\b') end -- cgit v1.2.3