summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-04-18 14:28:53 +1200
committerLars Wirzenius <liw@liw.fi>2010-04-18 14:28:53 +1200
commit65fefaa7d09e6c71772c8c7aee827063f72ae523 (patch)
treeab6033d405c594e93438e080f9e01bbee55a5baa
parent92dc0a5dc50ea0c10a8b6120af60f94b196408d3 (diff)
downloaddupfiles-65fefaa7d09e6c71772c8c7aee827063f72ae523.tar.gz
Report read speed.
-rwxr-xr-xdupfiles16
1 files changed, 12 insertions, 4 deletions
diff --git a/dupfiles b/dupfiles
index d95237c..14a5b2d 100755
--- a/dupfiles
+++ b/dupfiles
@@ -84,6 +84,8 @@ class DuplicateFileFinder(object):
total_bytes = sum(len(tuples) * size
for size, tuples in self.by_size.iteritems())
done_bytes = 0
+ start_time = time.time()
+
result = []
for size, tuples in self.by_size.iteritems():
by_checksum = dict()
@@ -93,17 +95,23 @@ class DuplicateFileFinder(object):
by_checksum[checksum] = set()
by_checksum[checksum].add(pathname)
done_bytes += size
- self.duplicates_progress(done_bytes, total_bytes)
+ self.duplicates_progress(done_bytes, total_bytes, start_time)
for names in by_checksum.itervalues():
if len(names) > 1:
result.append(names)
self.progress.finished()
return result
- def duplicates_progress(self, done, total):
- self.progress.write('%s/%s (%.1f%%) done' %
+ def duplicates_progress(self, done, total, started):
+ duration = time.time() - started
+ if duration < 1:
+ speed = 0
+ else:
+ speed = done / duration
+ self.progress.write('%s/%s (%.1f%%) done (%s/s)' %
(self.human_size(done), self.human_size(total),
- 100.0 * float(done) / float(total)))
+ 100.0 * float(done) / float(total),
+ self.human_size(speed)))
def human_size(self, size):
tab = [(1024**3, 'GiB'),