diff options
| -rw-r--r-- | pym/gentoolkit/revdep_rebuild/analyse.py | 37 | ||||
| -rw-r--r-- | pym/gentoolkit/revdep_rebuild/assign.py | 7 |
2 files changed, 40 insertions, 4 deletions
diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py index 3194f48..c118369 100644 --- a/pym/gentoolkit/revdep_rebuild/analyse.py +++ b/pym/gentoolkit/revdep_rebuild/analyse.py @@ -6,6 +6,7 @@ from __future__ import print_function import os import re +import time from portage.output import bold, blue, yellow, green @@ -15,6 +16,8 @@ from .collect import (prepare_search_dirs, parse_revdep_config, from .assign import assign_packages from .cache import save_cache +current_milli_time = lambda: int(round(time.time() * 1000)) + def scan_files(libs_and_bins, cmd_max_args, logger): '''Calls stuff.scan() and processes the data into a dictionary @@ -25,9 +28,16 @@ def scan_files(libs_and_bins, cmd_max_args, logger): @param logger: python style Logging function to use for output. @returns dict: {bit_length: {soname: {filename: set(needed)}}} ''' + stime = current_milli_time() scanned_files = {} # {bits: {soname: (filename, needed), ...}, ...} - for line in scan(['-nBF', '%F %f %S %n %M'], - libs_and_bins, cmd_max_args, logger): + lines = scan(['-nBF', '%F %f %S %n %M'], + libs_and_bins, cmd_max_args, logger) + ftime = current_milli_time() + logger.debug("\tscan_files(); total time to get scanelf data is " + "%d milliseconds" % (ftime-stime)) + stime = current_milli_time() + count = 0 + for line in lines: parts = line.split(' ') if len(parts) < 5: logger.error("\tscan_files(); error processing lib: %s" % line) @@ -46,9 +56,12 @@ def scan_files(libs_and_bins, cmd_max_args, logger): scanned_files[bits][soname] = {} if filename not in scanned_files[bits][soname]: scanned_files[bits][soname][filename] = set(needed) + count += 1 else: scanned_files[bits][soname][filename].update(needed) - + ftime = current_milli_time() + logger.debug("\tscan_files(); total filenames found: %d in %d milliseconds" + % (count, ftime-stime)) return scanned_files @@ -160,6 +173,8 @@ class LibCheck(object): scan_files(). Defaults to the class instance of scanned_files @ returns: dict: {bit_length: {found_lib: set(file_paths)}}. ''' + stime = current_milli_time() + count = 0 if not scanned_files: scanned_files = self.scanned_files found_libs = {} @@ -175,8 +190,13 @@ class LibCheck(object): except KeyError: try: found_libs[bits][l] = set([filename]) + count += 1 except KeyError: found_libs = {bits: {l: set([filename])}} + count += 1 + ftime = current_milli_time() + self.logger.debug("\tLibCheck.search(); total libs found: %d in %d milliseconds" + % (count, ftime-stime)) return found_libs @@ -188,6 +208,7 @@ class LibCheck(object): scan_files(). Defaults to the class instance of scanned_files @ returns: list: of filepaths from teh search results. ''' + stime = current_milli_time() if not scanned_files: scanned_files = self.scanned_files found_pathes = [] @@ -197,6 +218,9 @@ class LibCheck(object): for fp in sorted(files): self.logger.info('\t' +yellow('* ') + fp) found_pathes.append(fp) + ftime = current_milli_time() + self.logger.debug("\tLibCheck.process_results(); total filepaths found: " + "%d in %d milliseconds" % (len(found_pathes), ftime-stime)) return found_pathes @@ -220,6 +244,7 @@ def analyse(settings, logger, libraries=None, la_libraries=None, #TODO: add partial cache (for ex. only libraries) # when found for some reason + stime = current_milli_time() logger.warn(green(' * ') + bold('Collecting system binaries and libraries')) bin_dirs, lib_dirs = prepare_search_dirs(logger, settings) @@ -235,12 +260,16 @@ def analyse(settings, logger, libraries=None, la_libraries=None, '/lib64/modules', ]) ) - + ftime = current_milli_time() + logger.debug('\ttime to complete task: %d milliseconds' % (ftime-stime)) + stime = current_milli_time() logger.info(green(' * ') + bold('Collecting dynamic linking informations')) libraries, la_libraries, libraries_links, symlink_pairs = \ collect_libraries_from_dir(lib_dirs, masked_dirs, logger) binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logger) + ftime = current_milli_time() + logger.debug('\ttime to complete task: %d milliseconds' % (ftime-stime)) if settings['USE_TMP_FILES']: save_cache(logger=logger, diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py index 40d04b7..2df6532 100644 --- a/pym/gentoolkit/revdep_rebuild/assign.py +++ b/pym/gentoolkit/revdep_rebuild/assign.py @@ -8,6 +8,8 @@ from __future__ import print_function import os import re +import time +current_milli_time = lambda: int(round(time.time() * 1000)) import portage from portage import portdb @@ -23,6 +25,7 @@ def assign_packages(broken, logger, settings): ''' Finds and returns packages that owns files placed in broken. Broken is list of files ''' + stime = current_milli_time() assigned_pkgs = set() assigned_filenames = set() for group in os.listdir(settings['PKG_DIR']): @@ -53,6 +56,10 @@ def assign_packages(broken, logger, settings): broken_filenames = set(broken) orphaned = broken_filenames.difference(assigned_filenames) + ftime = current_milli_time() + logger.debug("\tassign_packages(); assigned " + "%d packages, %d orphans in %d milliseconds" + % (len(assigned_pkgs), len(orphaned), ftime-stime)) return (assigned_pkgs, orphaned) |
