diff options
author | Lars Wirzenius <liw@liw.fi> | 2010-04-18 14:28:53 +1200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2010-04-18 14:28:53 +1200 |
commit | 65fefaa7d09e6c71772c8c7aee827063f72ae523 (patch) | |
tree | ab6033d405c594e93438e080f9e01bbee55a5baa /dupfiles | |
parent | 92dc0a5dc50ea0c10a8b6120af60f94b196408d3 (diff) | |
download | dupfiles-65fefaa7d09e6c71772c8c7aee827063f72ae523.tar.gz |
Report read speed.
Diffstat (limited to 'dupfiles')
-rwxr-xr-x | dupfiles | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -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'), |