[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.44-601-gaff90f4
David Steele
dsteele at gmail.com
Mon May 28 08:33:19 UTC 2012
The following commit has been merged in the develop branch:
commit 87c662522a83aba52b52ada5054377d5f38131da
Author: David Steele <dsteele at gmail.com>
Date: Wed May 23 22:15:20 2012 -0400
piuparts-report - replace O(n^2) search in remove_old_logs with a hash
Reduces "Removing old log files" by 5+ minutes, totalling 26 minutes
diff --git a/debian/changelog b/debian/changelog
index 8dc795c..26ac16c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,6 +14,8 @@ piuparts (0.45) UNRELEASED; urgency=low
- Display reverse dependency counts and block counts to failure summaries.
- Sort the failed-testing and cannot-be-tested summaries by block count.
(Closes: #674498)
+ - Replace O(n^2) search in remove_old_logs() with a hash
+ piuparts-report run time improved 20% on mature environment.
[ Andreas Beckmann ]
* piuparts.py:
diff --git a/piuparts-report.py b/piuparts-report.py
old mode 100644
new mode 100755
index 86c316e..31b681c
--- a/piuparts-report.py
+++ b/piuparts-report.py
@@ -522,9 +522,15 @@ def copy_logs(logs_by_dir, output_dir):
def remove_old_logs(logs_by_dir, output_dir):
for vdir in logs_by_dir:
fulldir = os.path.join(output_dir, vdir)
+
+ # convert logs_by_dir array to a dict to avoid linear search
+ logs_dict = {}
+ for log in logs_by_dir[vdir]:
+ logs_dict[log] = 1
+
if os.path.exists(fulldir):
for basename in os.listdir(fulldir):
- if basename not in logs_by_dir[vdir]:
+ if not basename in logs_dict:
os.remove(os.path.join(fulldir, basename))
--
piuparts git repository
More information about the Piuparts-commits
mailing list