[csw-devel] SF.net SVN: gar:[14920] csw/mgar/gar/v2/lib/python/checkpkg_lib.py
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Tue Jun 28 11:25:37 CEST 2011
Revision: 14920
http://gar.svn.sourceforge.net/gar/?rev=14920&view=rev
Author: wahwah
Date: 2011-06-28 09:25:37 +0000 (Tue, 28 Jun 2011)
Log Message:
-----------
checkpkg: Memoizing GetPkgByPath
Speeds up execution of certain tests. In the case of CSWncurses, the analysis
time goes down from 17m to 1m30s.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/checkpkg_lib.py
Modified: csw/mgar/gar/v2/lib/python/checkpkg_lib.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg_lib.py 2011-06-28 09:23:38 UTC (rev 14919)
+++ csw/mgar/gar/v2/lib/python/checkpkg_lib.py 2011-06-28 09:25:37 UTC (rev 14920)
@@ -302,6 +302,7 @@
self.catrel = catrel
self.catalog = catalog
self.common_paths = {}
+ self.pkgs_by_path_cache = {}
if lines_dict:
self.lines_dict = lines_dict
else:
@@ -353,19 +354,22 @@
def GetPkgByPath(self, file_path):
"""Proxies calls to self.system_pkgmap."""
- pkgs_in_catalog = self.catalog.GetPkgByPath(
- file_path, self.osrel, self.arch, self.catrel)
- # This response comes from catalog; we need to simulate the state the
- # catalog would have if the set under test in the catalog. First, we
- # remove all packages that are under test.
- pkgs = set(pkgs_in_catalog.difference(set(self.pkg_set_files)))
- if file_path in self.pkgs_by_file:
- for pkg in self.pkgs_by_file[file_path]:
- pkgs.add(pkg)
- logging_response = pprint.pformat(pkgs)
- logging.debug("GetPkgByPath(%s).AndReturn(%s)"
- % (file_path, logging_response))
- return pkgs
+ key = (file_path, self.osrel, self.arch, self.catrel)
+ if not key in self.pkgs_by_path_cache:
+ pkgs_in_catalog = self.catalog.GetPkgByPath(
+ file_path, self.osrel, self.arch, self.catrel)
+ # This response comes from catalog; we need to simulate the state the
+ # catalog would have if the set under test in the catalog. First, we
+ # remove old versions of packages under test.
+ pkgs = set(pkgs_in_catalog.difference(set(self.pkg_set_files)))
+ if file_path in self.pkgs_by_file:
+ for pkg in self.pkgs_by_file[file_path]:
+ pkgs.add(pkg)
+ logging_response = pprint.pformat(pkgs)
+ logging.debug("GetPkgByPath(%s).AndReturn(%s)"
+ % (file_path, logging_response))
+ self.pkgs_by_path_cache[key] = pkgs
+ return self.pkgs_by_path_cache[key]
def GetInstalledPackages(self):
return self.catalog.GetInstalledPackages(
@@ -624,8 +628,10 @@
]
]
"""
- logging.debug("_ReportMissingDependencies(error_mgr, %s, %s, %s)",
- pkgname, declared_deps, pprint.pformat(req_pkgs_reasons))
+ # Disabling the logging, because pprint.pformat can take an awful lot of
+ # time.
+ # logging.debug("_ReportMissingDependencies(error_mgr, %s, %s, %s)",
+ # pkgname, declared_deps, pprint.pformat(req_pkgs_reasons))
missing_reasons_by_pkg = {}
for reason_group in req_pkgs_reasons:
for pkg, reason in reason_group:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list