Exemplo n.º 1
0
    def _GetTimelineBasedMeasurementOptions(self, options):
        """Return all timeline based measurements for the curren benchmark run.

    This includes the benchmark-configured measurements in
    CreateCoreTimelineBasedMeasurementOptions as well as the user-flag-
    configured options from --extra-chrome-categories and
    --extra-atrace-categories.
    """
        # TODO(sullivan): the benchmark options should all be configured in
        # CreateCoreTimelineBasedMeasurementOptions. Remove references to
        # CreateCoreTimelineBasedMeasurementOptions when it is fully deprecated.
        # In the short term, if the benchmark overrides
        # CreateCoreTimelineBasedMeasurementOptions use the overridden version,
        # otherwise call CreateCoreTimelineBasedMeasurementOptions.
        # https://github.com/catapult-project/catapult/issues/3450
        tbm_options = None
        assert not (
            class_util.IsMethodOverridden(
                Benchmark, self.__class__,
                'CreateTimelineBasedMeasurementOptions')
            and class_util.IsMethodOverridden(
                Benchmark, self.__class__,
                'CreateCoreTimelineBasedMeasurementOptions')
        ), ('Benchmarks should override CreateCoreTimelineBasedMeasurementOptions '
            'and NOT also CreateTimelineBasedMeasurementOptions.')
        if class_util.IsMethodOverridden(
                Benchmark, self.__class__,
                'CreateCoreTimelineBasedMeasurementOptions'):
            tbm_options = self.CreateCoreTimelineBasedMeasurementOptions()
        else:
            tbm_options = self.CreateTimelineBasedMeasurementOptions()
        if options and options.extra_chrome_categories:
            # If Chrome tracing categories for this benchmark are not already
            # enabled, there is probably a good reason why (for example, maybe
            # it is the benchmark that runs a BattOr without Chrome to get an energy
            # baseline). Don't change whether Chrome tracing is enabled.
            assert tbm_options.config.enable_chrome_trace, (
                'This benchmark does not support Chrome tracing.')
            tbm_options.config.chrome_trace_config.category_filter.AddFilterString(
                options.extra_chrome_categories)
        if options and options.extra_atrace_categories:
            # Many benchmarks on Android run without atrace by default. Hopefully the
            # user understands that atrace is only supported on Android when setting
            # this option.
            tbm_options.config.enable_atrace_trace = True

            categories = tbm_options.config.atrace_config.categories
            if type(categories) != list:
                # Categories can either be a list or comma-separated string.
                # https://github.com/catapult-project/catapult/issues/3712
                categories = categories.split(',')
            for category in options.extra_atrace_categories.split(','):
                if category not in categories:
                    categories.append(category)
            tbm_options.config.atrace_config.categories = categories
        if options and options.enable_systrace:
            tbm_options.config.chrome_trace_config.SetEnableSystrace()
        return tbm_options
Exemplo n.º 2
0
  def testClassNotOverridden(self):
    class Parent(object):
      def MethodShouldBeOverridden(self):
        pass

    class Child(Parent):
      def SomeOtherMethod(self):
        pass

    self.assertFalse(class_util.IsMethodOverridden(
        Parent, Child, 'MethodShouldBeOverridden'))
Exemplo n.º 3
0
  def testClassOverridden(self):
    class Parent(object):
      def MethodShouldBeOverridden(self):
        pass

    class Child(Parent):
      def MethodShouldBeOverridden(self):
        pass

    self.assertTrue(class_util.IsMethodOverridden(
        Parent, Child, 'MethodShouldBeOverridden'))
Exemplo n.º 4
0
  def testMultipleInheritance(self):
    class Aaa(object):
      def One(self):
        pass

    class Bbb(object):
      def Two(self):
        pass

    class Ccc(Aaa, Bbb):
      pass

    class Ddd(object):
      def Three(self):
        pass

    class Eee(Ddd):
      def Three(self):
        pass

    class Fff(Ccc, Eee):
      def One(self):
        pass

    class Ggg(object):
      def Four(self):
        pass

    class Hhh(Fff, Ggg):
      def Two(self):
        pass

    class Iii(Hhh):
      pass

    class Jjj(Iii):
      pass

    self.assertFalse(class_util.IsMethodOverridden(Aaa, Ccc, 'One'))
    self.assertTrue(class_util.IsMethodOverridden(Aaa, Fff, 'One'))
    self.assertTrue(class_util.IsMethodOverridden(Aaa, Hhh, 'One'))
    self.assertTrue(class_util.IsMethodOverridden(Aaa, Jjj, 'One'))
    self.assertFalse(class_util.IsMethodOverridden(Bbb, Ccc, 'Two'))
    self.assertTrue(class_util.IsMethodOverridden(Bbb, Hhh, 'Two'))
    self.assertTrue(class_util.IsMethodOverridden(Bbb, Jjj, 'Two'))
    self.assertFalse(class_util.IsMethodOverridden(Eee, Fff, 'Three'))
Exemplo n.º 5
0
  def testGrandchildNotOverridden(self):
    class Parent(object):
      def MethodShouldBeOverridden(self):
        pass

    class Child(Parent):
      def MethodShouldBeOverridden(self):
        pass

    class Grandchild(Child):
      def SomeOtherMethod(self):
        pass

    self.assertTrue(class_util.IsMethodOverridden(
        Parent, Grandchild, 'MethodShouldBeOverridden'))