def __init__(self, adb):
    Hardware.__init__(self)
    self.warmup_time = 5
    self._adb = adb

    if self._adb.root():
      self._adb.remount()
    def __init__(self, adb):
        Hardware.__init__(self)
        self.warmup_time = 5
        self._adb = adb

        if self._adb.root():
            self._adb.remount()
예제 #3
0
  def print_debug_diagnostics(self):
    # search for and print thermal trip points that may have been exceeded.
    self._adb.shell('''\
      THERMALDIR=/sys/class/thermal
      if [ ! -d $THERMALDIR ]; then
        exit
      fi
      for ZONE in $(cd $THERMALDIR; echo thermal_zone*); do
        cd $THERMALDIR/$ZONE
        if [ ! -e mode ] || grep -Fxqv enabled mode || [ ! -e trip_point_0_temp ]; then
          continue
        fi
        TEMP=$(cat temp)
        TRIPPOINT=trip_point_0_temp
        if [ $TEMP -le $(cat $TRIPPOINT) ]; then
          echo "$ZONE ($(cat type)): temp=$TEMP <= $TRIPPOINT=$(cat $TRIPPOINT)" 1>&2
        else
          let i=1
          while [ -e trip_point_${i}_temp ] &&
                [ $TEMP -gt $(cat trip_point_${i}_temp) ]; do
            TRIPPOINT=trip_point_${i}_temp
            let i=i+1
          done
          echo "$ZONE ($(cat type)): temp=$TEMP > $TRIPPOINT=$(cat $TRIPPOINT)" 1>&2
        fi
      done''')

    Hardware.print_debug_diagnostics(self)
예제 #4
0
    def __init__(self, adb):
        Hardware.__init__(self)
        self.warmup_time = 5
        self._adb = adb
        self.desiredClock = 0.66

        if self._adb.root():
            self._adb.remount()
  def __init__(self, adb):
    Hardware.__init__(self)
    self.warmup_time = 5
    self._adb = adb

    if self._adb.root():
      self._adb.remount()
      self._initial_ASLR = \
        self._adb.check('cat /proc/sys/kernel/randomize_va_space')
예제 #6
0
 def __init__(self, adb):
   Hardware.__init__(self)
   self.warmup_time = 5
   self._adb = adb
   self._is_root = self._adb.attempt_root()
   if self._is_root:
     self._adb.remount()
   self._initial_airplane_mode = None
   self._initial_location_providers = None
   self._initial_ASLR = None
예제 #7
0
    def __enter__(self):
        Hardware.__enter__(self)
        if not self._adb.is_root() and self._adb.root():
            self._adb.remount()

        self._adb.shell('\n'.join([
            # turn on airplane mode.
            '''
      settings put global airplane_mode_on 1''',

            # disable GPS.
            '''
      settings put secure location_providers_allowed -gps
      settings put secure location_providers_allowed -wifi
      settings put secure location_providers_allowed -network'''
        ]))

        if self._adb.is_root():

            # For explanation of variance reducing steps, see
            # https://g3doc.corp.google.com/engedu/portal/android/g3doc/learn/develop/performance/content/best/reliable-startup-latency.md?cl=head

            self._adb.shell('\n'.join([
                # disable bluetooth, wifi, and mobile data.
                '''
        service call bluetooth_manager 8
        svc wifi disable
        svc data disable''',

                # kill the gui.
                '''
        setprop ctl.stop media
        setprop ctl.stop zygote
        setprop ctl.stop surfaceflinger
        setprop ctl.stop drm''',

                # disable ASLR
                '''
        echo 0 > /proc/sys/kernel/randomize_va_space''',
            ]))

            self.lock_top_three_cores()

            self.lock_adreno_gpu()

        else:
            print("WARNING: no adb root access; results may be unreliable.",
                  file=sys.stderr)

        return self
  def __exit__(self, exception_type, exception_value, traceback):
    Hardware.__exit__(self, exception_type, exception_value, traceback)

    if self._adb.is_root():
      self._adb.shell('\n'.join([
        # restore ASLR.
        '''
        echo %s > /proc/sys/kernel/randomize_va_space''' % self._initial_ASLR,

        # revive the gui.
        '''
        setprop ctl.start drm
        setprop ctl.start surfaceflinger
        setprop ctl.start zygote
        setprop ctl.start media''']))
예제 #9
0
  def __enter__(self):
    Hardware.__enter__(self)
    if not self._adb.is_root() and self._adb.root():
      self._adb.remount()

    self._adb.shell('\n'.join([
      # turn on airplane mode.
      '''
      settings put global airplane_mode_on 1''',

      # disable GPS.
      '''
      settings put secure location_providers_allowed -gps
      settings put secure location_providers_allowed -wifi
      settings put secure location_providers_allowed -network''']))

    if self._adb.is_root():

      self._adb.shell('\n'.join([
        # disable bluetooth, wifi, and mobile data.
        '''
        service call bluetooth_manager 8
        svc wifi disable
        svc data disable''',

        # kill the gui.
        '''
        setprop ctl.stop media
        setprop ctl.stop zygote
        setprop ctl.stop surfaceflinger
        setprop ctl.stop drm''',

        # disable ASLR
        '''
        echo 0 > /proc/sys/kernel/randomize_va_space''',

        # stop services which can change clock speed
        '''
        stop thermal-engine
        stop perfd''']))

      self.lock_top_three_cores()

    else:
      print("WARNING: no adb root access; results may be unreliable.",
            file=sys.stderr)

    return self
예제 #10
0
def main():
    # Delimiter is ',' or ' ', skip if nested inside parens (e.g. gpu(a=b,c=d)).
    DELIMITER = r'[, ](?!(?:[^(]*\([^)]*\))*[^()]*\))'
    configs = re.split(DELIMITER, FLAGS.config)
    skps = _path.find_skps(FLAGS.skps)

    if FLAGS.adb:
        adb = Adb(FLAGS.device_serial)
        model = adb.get_device_model()
        if model == 'Pixel C':
            from _hardware_pixel_c import HardwarePixelC
            hardware = HardwarePixelC(adb)
        else:
            from _hardware_android import HardwareAndroid
            print(
                "WARNING: %s: don't know how to monitor this hardware; results "
                "may be unreliable." % model,
                file=sys.stderr)
            hardware = HardwareAndroid(adb)
    else:
        hardware = Hardware()

    with hardware:
        if hardware.kick_in_time:
            print(
                "sleeping %i seconds to allow hardware settings to kick in..."
                % hardware.kick_in_time,
                file=sys.stderr)
            time.sleep(hardware.kick_in_time)
        run_benchmarks(configs, skps, hardware)
예제 #11
0
파일: skpbench.py 프로젝트: seem-sky/skia
def main():
    # Delimiter is ',' or ' ', skip if nested inside parens (e.g. gpu(a=b,c=d)).
    DELIMITER = r'[, ](?!(?:[^(]*\([^)]*\))*[^()]*\))'
    configs = re.split(DELIMITER, FLAGS.config)
    skps = _path.find_skps(FLAGS.skps)

    if FLAGS.adb:
        adb = Adb(FLAGS.device_serial)
        model = adb.get_device_model()
        if model == 'Pixel C':
            from _hardware_pixel_c import HardwarePixelC
            hardware = HardwarePixelC(adb)
        elif model == 'Nexus 6P':
            from _hardware_nexus_6p import HardwareNexus6P
            hardware = HardwareNexus6P(adb)
        else:
            from _hardware_android import HardwareAndroid
            print(
                "WARNING: %s: don't know how to monitor this hardware; results "
                "may be unreliable." % model,
                file=sys.stderr)
            hardware = HardwareAndroid(adb)
    else:
        hardware = Hardware()

    with hardware:
        SKPBench.run_warmup(hardware.warmup_time)
        run_benchmarks(configs, skps, hardware)
예제 #12
0
def main():
    # Delimiter is ',' or ' ', skip if nested inside parens (e.g. gpu(a=b,c=d)).
    DELIMITER = r'[, ](?!(?:[^(]*\([^)]*\))*[^()]*\))'
    configs = re.split(DELIMITER, FLAGS.config)
    skps = _path.find_skps(FLAGS.skps)

    if FLAGS.adb:
        adb = Adb(FLAGS.device_serial, echo=(FLAGS.verbosity >= 5))
        model = adb.check('getprop ro.product.model').strip()
        if model == 'Pixel C':
            from _hardware_pixel_c import HardwarePixelC
            hardware = HardwarePixelC(adb)
        elif model == 'Nexus 6P':
            from _hardware_nexus_6p import HardwareNexus6P
            hardware = HardwareNexus6P(adb)
        else:
            from _hardware_android import HardwareAndroid
            print(
                "WARNING: %s: don't know how to monitor this hardware; results "
                "may be unreliable." % model,
                file=sys.stderr)
            hardware = HardwareAndroid(adb)
    else:
        hardware = Hardware()

    with hardware:
        SKPBench.run_warmup(hardware.warmup_time, configs[0])
        if FLAGS.resultsfile:
            with open(FLAGS.resultsfile, mode='a+') as resultsfile:
                run_benchmarks(configs,
                               skps,
                               hardware,
                               resultsfile=resultsfile)
        else:
            run_benchmarks(configs, skps, hardware)
  def __enter__(self):
    self._adb.shell('\n'.join([
      # turn on airplane mode.
      '''
      settings put global airplane_mode_on 1''',

      # disable GPS.
      '''
      for MODE in gps wifi network; do
        settings put secure location_providers_allowed -$MODE
      done''']))

    if self._adb.is_root():
      self._adb.shell('\n'.join([
        # disable bluetooth, wifi, and mobile data.
        '''
        service call bluetooth_manager 8
        svc wifi disable
        svc data disable''',

        # kill the gui.
        '''
        setprop ctl.stop media
        setprop ctl.stop zygote
        setprop ctl.stop surfaceflinger
        setprop ctl.stop drm''',

        # disable ASLR
        '''
        echo 0 > /proc/sys/kernel/randomize_va_space''']))
    else:
      print("WARNING: no adb root access; results may be unreliable.",
            file=sys.stderr)

    return Hardware.__enter__(self)
예제 #14
0
def main():
    # Delimiter is ',' or ' ', skip if nested inside parens (e.g. gpu(a=b,c=d)).
    DELIMITER = r'[, ](?!(?:[^(]*\([^)]*\))*[^()]*\))'
    configs = re.split(DELIMITER, FLAGS.config)
    srcs = _path.find_skps(FLAGS.srcs)
    assert srcs

    if FLAGS.adb:
        adb = Adb(FLAGS.device_serial,
                  FLAGS.adb_binary,
                  echo=(FLAGS.verbosity >= 5))
        from _hardware_android import HardwareAndroid

        model = adb.check('getprop ro.product.model').strip()
        if model == 'Pixel C':
            from _hardware_pixel_c import HardwarePixelC
            hardware = HardwarePixelC(adb)
        elif model == 'Pixel' or model == "Pixel XL":
            from _hardware_pixel import HardwarePixel
            hardware = HardwarePixel(adb)
        elif model == 'Pixel 2':
            from _hardware_pixel2 import HardwarePixel2
            hardware = HardwarePixel2(adb)
        elif model == 'Nexus 6P':
            from _hardware_nexus_6p import HardwareNexus6P
            hardware = HardwareNexus6P(adb)
        else:
            print(
                "WARNING: %s: don't know how to monitor this hardware; results "
                "may be unreliable." % model,
                file=sys.stderr)
            hardware = HardwareAndroid(adb)

        if FLAGS.lock_clocks:
            hardware.__enter__()
            print(
                "Entered benchmarking mode, not running benchmarks. Reboot to restore."
            )
            return

        if FLAGS.clock_speed:
            hardware.setDesiredClock(FLAGS.clock_speed)
    else:
        hardware = Hardware()

    if FLAGS.resultsfile:
        with open(FLAGS.resultsfile, mode='a+') as resultsfile:
            run_benchmarks(configs, srcs, hardware, resultsfile=resultsfile)
    else:
        run_benchmarks(configs, srcs, hardware)
예제 #15
0
  def __exit__(self, exception_type, exception_value, traceback):
    Hardware.__exit__(self, exception_type, exception_value, traceback)

    if self._is_root:
      # restore ASLR.
      self._adb.shell('echo %s > /proc/sys/kernel/randomize_va_space' %
                      self._initial_ASLR)

      # revive the gui.
      self._adb.shell('''\
        setprop ctl.start drm &&
        setprop ctl.start surfaceflinger &&
        setprop ctl.start zygote &&
        setprop ctl.start media''')
    else:
      # restore GPS (doesn't seem to work if we killed the gui).
      self._adb.shell('''\
        for PROVIDER in %s; do
          settings put secure location_providers_allowed +$PROVIDER
        done''' % self._initial_location_providers)

      # restore airplane mode (doesn't seem to work if we killed the gui).
      self._adb.shell('settings put global airplane_mode_on %s' %
                      self._initial_airplane_mode)
예제 #16
0
파일: skpbench.py 프로젝트: rust-skia/skia
def main():
    # Delimiter is ',' or ' ', skip if nested inside parens (e.g. gpu(a=b,c=d)).
    DELIMITER = r'[, ](?!(?:[^(]*\([^)]*\))*[^()]*\))'
    configs = re.split(DELIMITER, FLAGS.config)
    srcs = _path.find_skps(FLAGS.srcs)
    assert srcs

    if FLAGS.adb:
        adb = Adb(FLAGS.device_serial,
                  FLAGS.adb_binary,
                  echo=(FLAGS.verbosity >= 5))
        model = adb.check('getprop ro.product.model').strip()
        if model == 'Pixel C':
            from _hardware_pixel_c import HardwarePixelC
            hardware = HardwarePixelC(adb)
        elif model == 'Pixel':
            from _hardware_pixel import HardwarePixel
            hardware = HardwarePixel(adb)
        elif model == 'Pixel 2':
            from _hardware_pixel2 import HardwarePixel2
            hardware = HardwarePixel2(adb)
        elif model == 'Nexus 6P':
            from _hardware_nexus_6p import HardwareNexus6P
            hardware = HardwareNexus6P(adb)
        elif FLAGS.force:
            from _hardware_android import HardwareAndroid
            print(
                "WARNING: %s: don't know how to monitor this hardware; results "
                "may be unreliable." % model,
                file=sys.stderr)
            hardware = HardwareAndroid(adb)
        else:
            raise Exception("%s: don't know how to monitor this hardware. "
                            "Use --force to bypass this warning." % model)
    else:
        hardware = Hardware()

    if FLAGS.resultsfile:
        with open(FLAGS.resultsfile, mode='a+') as resultsfile:
            run_benchmarks(configs, srcs, hardware, resultsfile=resultsfile)
    else:
        run_benchmarks(configs, srcs, hardware)
예제 #17
0
  def __enter__(self):
    # turn on airplane mode.
    self._initial_airplane_mode = \
      self._adb.check('settings get global airplane_mode_on')
    self._adb.shell('settings put global airplane_mode_on 1')

    # disable GPS.
    self._initial_location_providers = \
      self._adb.check('settings get secure location_providers_allowed')
    self._initial_location_providers = \
      self._initial_location_providers.replace(',', ' ')
    self._adb.shell('''\
      for PROVIDER in %s; do
        settings put secure location_providers_allowed -$PROVIDER
      done''' % self._initial_location_providers)

    if self._is_root:
      # disable bluetooth, wifi, and mobile data.
      # TODO: can we query these initial values?
      self._adb.shell('''\
        service call bluetooth_manager 8 &&
        svc wifi disable &&
        svc data disable''')

      # kill the gui.
      self._adb.shell('''\
        setprop ctl.stop media &&
        setprop ctl.stop zygote &&
        setprop ctl.stop surfaceflinger &&
        setprop ctl.stop drm''')

      # disable ASLR.
      self._initial_ASLR = \
        self._adb.check('cat /proc/sys/kernel/randomize_va_space')
      self._adb.shell('echo 0 > /proc/sys/kernel/randomize_va_space')
    else:
      print("WARNING: no adb root access; results may be unreliable.",
            file=sys.stderr)

    return Hardware.__enter__(self)
예제 #18
0
 def sanity_check(self):
   Hardware.sanity_check(self)
예제 #19
0
 def sleep(self, sleeptime):
   Hardware.sleep(self, sleeptime)
 def __exit__(self, exception_type, exception_value, traceback):
   Hardware.__exit__(self, exception_type, exception_value, traceback)
   self._adb.reboot() # some devices struggle waking up; just hard reboot.
 def __exit__(self, exception_type, exception_value, traceback):
     Hardware.__exit__(self, exception_type, exception_value, traceback)
     self._adb.reboot(
     )  # some devices struggle waking up; just hard reboot.