示例#1
0
    def test_get_python_names(self):
        self.assertEqual(utils.get_python_names('/usr/bin/python2.7',
                                                '/usr/bin/python3.5'),
                         ('python2.7', 'python3.5'))

        self.assertEqual(utils.get_python_names('/bin/python2.7',
                                                '/usr/bin/python2.7'),
                         ('/bin/python2.7', '/usr/bin/python2.7'))
示例#2
0
    def _compare_to(self):
        # Use lazy import to limit imports on 'import pyperf'
        from pyperf._compare import timeit_compare_benchs
        from pyperf._master import Master

        args = self.args
        python_ref = args.compare_to
        python_changed = args.python

        multiline = self._multiline_output()
        if args.python_names:
            name_ref, name_changed = args.python_names
        else:
            name_ref, name_changed = get_python_names(python_ref,
                                                      python_changed)

        benchs = []
        for python, name in ((python_ref, name_ref), (python_changed,
                                                      name_changed)):
            if self._worker_task > 0:
                print()

            if multiline:
                display_title('Benchmark %s' % name)
            elif not args.quiet:
                print(name, end=': ')

            bench = Master(self, python=python).create_bench()
            benchs.append(bench)

            if multiline:
                self._display_result(bench)
            elif not args.quiet:
                print(' ' + format_result_value(bench))

            if multiline:
                print()
            elif not args.quiet:
                warnings = format_checks(bench)
                if warnings:
                    print()
                    for line in warnings:
                        print(line)
                    print()

        if multiline:
            display_title('Compare')
        elif not args.quiet:
            print()
        timeit_compare_benchs(name_ref, benchs[0], name_changed, benchs[1],
                              args)