How to use the diffoscope.profiling.profile function in diffoscope

To help you get started, we’ve selected a few diffoscope examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github anthraxx / diffoscope / diffoscope / main.py View on Github external
parser = create_parser()
            parsed_args = parser.parse_args(args)
        sys.exit(run_diffoscope(parsed_args))
    except KeyboardInterrupt:
        logger.info('Keyboard Interrupt')
        sys.exit(2)
    except BrokenPipeError:
        sys.exit(2)
    except Exception:
        traceback.print_exc()
        if parsed_args and parsed_args.debugger:
            import pdb
            pdb.post_mortem()
        sys.exit(2)
    finally:
        with profile('main', 'cleanup'):
            clean_all_temp_files()

        # Print profiling output at the very end
        if parsed_args is not None:
            ProfileManager().finish(parsed_args)
github anthraxx / diffoscope / diffoscope / difference.py View on Github external
def feeder(out_file):
        with profile('command', command.cmdline()[0]):
            end_nl = make_feeder_from_raw_reader(command.stdout, command.filter)(out_file)
            if command.poll() is None:
                command.terminate()
            returncode = command.wait()
        if returncode not in (0, -signal.SIGTERM):
            raise subprocess.CalledProcessError(returncode, command.cmdline(), output=command.stderr.getvalue())
        return end_nl
    return feeder
github anthraxx / diffoscope / diffoscope / main.py View on Github external
maybe_set_limit(Config(), parsed_args, "max_report_size")
    maybe_set_limit(Config(), parsed_args, "max_text_report_size")
    maybe_set_limit(Config(), parsed_args, "max_report_child_size")
    # need to set them in this order due to Config._check_constraints
    maybe_set_limit(Config(), parsed_args, "max_diff_block_lines_saved")
    maybe_set_limit(Config(), parsed_args, "max_diff_block_lines_parent")
    maybe_set_limit(Config(), parsed_args, "max_diff_block_lines")
    maybe_set_limit(Config(), parsed_args, "max_diff_input_lines")
    Config().fuzzy_threshold = parsed_args.fuzzy_threshold
    Config().new_file = parsed_args.new_file
    Config().excludes = parsed_args.excludes
    set_locale()
    logger.debug('Starting comparison')
    ProgressManager().setup(parsed_args)
    with Progress(1, parsed_args.path1):
        with profile('main', 'outputs'):
            difference = compare_root_paths(
                parsed_args.path1, parsed_args.path2)
    ProgressManager().finish()
    # Generate an empty, dummy diff to write, saving the exit code first.
    has_differences = bool(difference is not None)
    if difference is None and parsed_args.output_empty:
        difference = Difference(None, parsed_args.path1, parsed_args.path2)
    with profile('main', 'outputs'):
        output_all(difference, parsed_args, has_differences)
    return 1 if has_differences else 0
github anthraxx / diffoscope / diffoscope / comparators / utils / archive.py View on Github external
def path(self):
        if self._path is None:
            logger.debug("Unpacking %s from %s", self._name, self.container.source.name)
            assert self._temp_dir is None
            self._temp_dir = get_temporary_directory()
            with profile('container_extract', self.container):
                self._path = self.container.extract(self._name, self._temp_dir.name)
        return self._path
github anthraxx / diffoscope / diffoscope / comparators / utils / compare.py View on Github external
if any_excluded(file1.name, file2.name):
        return None

    with profile('has_same_content_as', file1):
        if file1.has_same_content_as(file2):
            logger.debug("has_same_content_as returned True; skipping further comparisons")
            return None
    specialize(file1)
    specialize(file2)
    if isinstance(file1, MissingFile):
        file1.other_file = file2
    elif isinstance(file2, MissingFile):
        file2.other_file = file1
    elif file1.__class__.__name__ != file2.__class__.__name__:
        return file1.compare_bytes(file2, source)
    with profile('compare_files (cumulative)', file1):
        return file1.compare(file2, source)
github anthraxx / diffoscope / diffoscope / comparators / utils / __init__.py View on Github external
def path(self):
        if self._path is None:
            logger.debug('unpacking %s', self._name)
            assert self._temp_dir is None
            self._temp_dir = get_temporary_directory()
            with profile('container_extract', self.container):
                self._path = self.container.extract(self._name, self._temp_dir.name)
        return self._path
github anthraxx / diffoscope / diffoscope / tools.py View on Github external
def tool_check(*args, **kwargs):
                with profile('command', command):
                    return original_function(*args, **kwargs)
        else:
github anthraxx / diffoscope / diffoscope / comparators / utils / archive.py View on Github external
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        with profile('open_archive', self):
            self._archive = self.open_archive()