Ejemplo n.º 1
0
    def run(self, exp_dir, video_url, video_duration_s, collect=''):

        # Initialize energy meter results
        nrg_report = None

        # Unlock device screen (assume no password required)
        System.menu(self.target)
        # Press Back button to be sure we run the video from the start
        System.back(self.target)

        # Use the monkey tool to start YouTube without playing any video.
        # This allows to subsequently set the screen orientation to LANDSCAPE
        # and to reset the frame statistics.
        System.monkey(self.target, self.package)

        # Force screen in LANDSCAPE mode
        Screen.set_orientation(self.target, portrait=False)

        System.gfxinfo_reset(self.target, self.package)
        sleep(1)

        # Start YouTube video on the target device
        System.start_action(self.target, self.action, video_url)
        # Allow the activity to start
        sleep(1)

        # Start energy collection
        if 'energy' in collect and self.te.emeter:
            self.te.emeter.reset()

        # Wait until the end of the video
        self.logger.info("Play video for %d [s]", video_duration_s)
        sleep(video_duration_s)

        # Stop energy collection
        if 'energy' in collect and self.te.emeter:
            nrg_report = self.te.emeter.report(exp_dir)

        # Get frame stats
        db_file = os.path.join(exp_dir, "framestats.txt")
        System.gfxinfo_get(self.target, self.package, db_file)

        # Close the app without clearing the local data to
        # avoid the dialog to select the account at next start
        System.force_stop(self.target, self.package, clear=False)

        # Go back to home screen
        System.home(self.target)

        # Switch back to screen auto rotation
        Screen.set_orientation(self.target, auto=True)

        return db_file, nrg_report
Ejemplo n.º 2
0
    def run(self, exp_dir, video_url, video_duration_s, collect=''):

        # Initialize energy meter results
        nrg_report = None

        # Unlock device screen (assume no password required)
        System.menu(self.target)
        # Press Back button to be sure we run the video from the start
        System.back(self.target)

        # Use the monkey tool to start YouTube without playing any video.
        # This allows to subsequently set the screen orientation to LANDSCAPE
        # and to reset the frame statistics.
        System.monkey(self.target, self.package)

        # Force screen in LANDSCAPE mode
        Screen.set_orientation(self.target, portrait=False)

        System.gfxinfo_reset(self.target, self.package)
        sleep(1)

        # Start YouTube video on the target device
        System.start_action(self.target, self.action, video_url)
        # Allow the activity to start
        sleep(1)

        # Start energy collection
        if 'energy' in collect and self.te.emeter:
            self.te.emeter.reset()

        # Wait until the end of the video
        self.logger.info("Play video for %d [s]", video_duration_s)
        sleep(video_duration_s)

        # Stop energy collection
        if 'energy' in collect and self.te.emeter:
            nrg_report = self.te.emeter.report(exp_dir)

        # Get frame stats
        db_file = os.path.join(exp_dir, "framestats.txt")
        System.gfxinfo_get(self.target, self.package, db_file)

        # Close the app without clearing the local data to
        # avoid the dialog to select the account at next start
        System.force_stop(self.target, self.package, clear=False)

        # Go back to home screen
        System.home(self.target)

        # Switch back to screen auto rotation
        Screen.set_orientation(self.target, auto=True)

        return db_file, nrg_report
Ejemplo n.º 3
0
    def run(self, out_dir, location_search, swipe_count=5, collect=''):
        """
        Run single Gmaps workload.

        :param out_dir: Path to experiment directory where to store results.
        :type out_dir: str

        :param location_search: Search string to be used in GMaps
        :type location_search: str

        :param swipe_count: Number of sets of (left, right, up, down) swipes to do
        :type swipe_count: int

        :param collect: Specifies what to collect. Possible values:
            - 'energy'
            - 'systrace'
            - 'ftrace'
            - any combination of the above
        :type collect: list(str)
        """

        # Keep track of mandatory parameters
        self.out_dir = out_dir
        self.collect = collect

        # Set min brightness
        Screen.set_brightness(self._target, auto=False, percent=0)
        # Unlock device screen (assume no password required)
        Screen.unlock(self._target)

        # Use the monkey tool to start GMaps
        # This allows to subsequently set the screen orientation to LANDSCAPE
        # and to reset the frame statistics.
        System.monkey(self._target, self.package)

        # Force screen in PORTRAIT  mode
        Screen.set_orientation(self._target, portrait=True)

        System.gfxinfo_reset(self._target, self.package)
        sleep(1)

        # Start GMaps on the target device
        loc_url = 'geo:0,0?q='
        loc_url += '+'.join(location_search.split())
        System.start_action(self._target, self.action, loc_url)
        # Allow the activity to start
        sleep(1)

        script = TargetScript(self._te, "gmaps_swiper.sh")
        self._log.debug('Accumulating commands')

        for i in range(swipe_count):
            System.hswipe(script, 20, 80, 100, True)
            script.append('sleep 1')
            System.hswipe(script, 20, 80, 100, False)
            script.append('sleep 1')
            System.vswipe(script, 40, 60, 100, True)
            script.append('sleep 1')
            System.vswipe(script, 40, 60, 100, False)
            script.append('sleep 1')

        self._log.debug('Accumulation done')

        # Push script to the target
        script.push()

        self._log.info('Opening GMaps to [%s]', loc_url)
        # Let GMaps zoom in on the location
        sleep(2)

        self.tracingStart()

        self._log.info('Launching target script')
        script.run()
        self._log.info('Target script ended')

        self.tracingStop()

        # Get frame stats
        self.db_file = os.path.join(out_dir, "framestats.txt")
        System.gfxinfo_get(self._target, self.package, self.db_file)

        # Close the app without clearing the local data to
        # avoid the dialog to select the account at next start
        System.force_stop(self._target, self.package, clear=False)

        # Go back to home screen
        System.home(self._target)

        # Set brightness back to auto
        Screen.set_brightness(self._target, auto=True)

        # Switch back to screen auto rotation
        Screen.set_orientation(self._target, auto=True)
    def run(self, out_dir, duration_s, brightness, filepath, collect=''):
        """
        Run single display image workload.

        :param out_dir: Path to experiment directory where to store results.
        :type out_dir: str

        :param duration_s: Duration of test
        :type duration_s: int

        :param brightness: Brightness of the screen 0-100
        :type brightness: int

        :param out_dir: Path to the image to display
        :type out_dir: str

        :param collect: Specifies what to collect. Possible values:
            - 'energy'
            - 'time_in_state'
            - 'systrace'
            - 'ftrace'
            - any combination of the above, except energy and display-energy
              cannot be collected simultaneously.
        :type collect: list(str)
        """

        # Keep track of mandatory parameters
        self.out_dir = out_dir
        self.collect = collect

        # Set brightness
        Screen.set_brightness(self._target, auto=False, percent=brightness)

        # Set timeout to be sufficiently longer than the duration of the test
        Screen.set_timeout(self._target, seconds=(duration_s+60))

        # Turn on airplane mode
        System.set_airplane_mode(self._target, on=True)

        # Unlock device screen (assume no password required)
        Screen.unlock(self._target)

        # Push the image to the device
        device_filepath = '/data/local/tmp/image'
        self._target.push(filepath, device_filepath)
        sleep(1)

        # Put image on the screen
        System.start_action(self._target, self.action,
                '-t image/* -d file://{}'.format(device_filepath))
        sleep(1)

        # Dimiss the navigation bar by tapping the center of the screen
        System.tap(self._target, 50, 50)

        self.tracingStart(screen_always_on=False)

        self._log.info('Waiting for duration {}'.format(duration_s))
        sleep(duration_s)

        self.tracingStop(screen_always_on=False)

        # Close app and dismiss image
        System.force_stop(self._target, self.package, clear=True)

        # Remove image
        self._target.execute('rm /data/local/tmp/image')

        Screen.set_defaults(self._target)
        System.set_airplane_mode(self._target, on=False)

        Screen.set_screen(self._target, on=False)
Ejemplo n.º 5
0
    def run(self, out_dir, video_url, video_duration_s, collect=''):
        """
        Run single YouTube workload.

        :param out_dir: Path to experiment directory where to store results.
        :type out_dir: str

        :param video_url: Video URL to be played
        :type video_url: str

        :param video_duration_s: Play video for this required number of seconds
        :type video_duration_s: int

        :param collect: Specifies what to collect. Possible values:
            - 'energy'
            - 'systrace'
            - 'ftrace'
            - any combination of the above
        :type collect: list(str)
        """

        # Keep track of mandatory parameters
        self.out_dir = out_dir
        self.collect = collect

        # Unlock device screen (assume no password required)
        Screen.unlock(self._target)

        # Stop youtube if already running
        System.force_stop(self._target, self.package)

        # Use the monkey tool to start YouTube without playing any video.
        # This allows to subsequently set the screen orientation to LANDSCAPE
        # and to reset the frame statistics.
        System.monkey(self._target, self.package)

        # Force screen in LANDSCAPE mode
        Screen.set_orientation(self._target, portrait=False)

        # Set min brightness
        Screen.set_brightness(self._target, auto=False, percent=0)

        System.gfxinfo_reset(self._target, self.package)
        sleep(1)

        # Start YouTube video on the target device
        System.start_action(self._target, self.action, video_url)
        # Allow the activity to start
        sleep(1)

        # Wait until the end of the video
        self.tracingStart()
        self._log.info('Play video for %d [s]', video_duration_s)
        sleep(video_duration_s)
        self.tracingStop()

        # Get frame stats
        self.db_file = os.path.join(out_dir, "framestats.txt")
        System.gfxinfo_get(self._target, self.package, self.db_file)

        # Close the app without clearing the local data to
        # avoid the dialog to select the account at next start
        System.force_stop(self._target, self.package, clear=False)

        # Go back to home screen
        System.home(self._target)

        # Switch back to screen auto rotation
        Screen.set_orientation(self._target, auto=True)
        # Set brightness back to auto
        Screen.set_brightness(self._target, auto=True)
Ejemplo n.º 6
0
    def run(self, out_dir, video_url, video_duration_s, collect=''):
        """
        Run single YouTube workload.

        :param out_dir: Path to experiment directory where to store results.
        :type out_dir: str

        :param video_url: Video URL to be played
        :type video_url: str

        :param video_duration_s: Play video for this required number of seconds
        :type video_duration_s: int

        :param collect: Specifies what to collect. Possible values:
            - 'energy'
            - 'systrace'
            - 'ftrace'
            - any combination of the above
        :type collect: list(str)
        """

        # Keep track of mandatory parameters
        self.out_dir = out_dir
        self.collect = collect

        # Unlock device screen (assume no password required)
        Screen.unlock(self._target)

        # Stop youtube if already running
        System.force_stop(self._target, self.package)

        # Use the monkey tool to start YouTube without playing any video.
        # This allows to subsequently set the screen orientation to LANDSCAPE
        # and to reset the frame statistics.
        System.monkey(self._target, self.package)

        # Force screen in LANDSCAPE mode
        Screen.set_orientation(self._target, portrait=False)

        # Set min brightness
        Screen.set_brightness(self._target, auto=False, percent=0)

        System.gfxinfo_reset(self._target, self.package)
        sleep(1)

        # Start YouTube video on the target device
        System.start_action(self._target, self.action, video_url)
        # Allow the activity to start
        sleep(1)

        # Wait until the end of the video
        self.tracingStart()
        self._log.info('Play video for %d [s]', video_duration_s)
        sleep(video_duration_s)
        self.tracingStop()

        # Get frame stats
        self.db_file = os.path.join(out_dir, "framestats.txt")
        System.gfxinfo_get(self._target, self.package, self.db_file)

        # Close the app without clearing the local data to
        # avoid the dialog to select the account at next start
        System.force_stop(self._target, self.package, clear=False)

        # Go back to home screen
        System.home(self._target)

        # Switch back to screen auto rotation
        Screen.set_orientation(self._target, auto=True)
        # Set brightness back to auto
        Screen.set_brightness(self._target, auto=True)
Ejemplo n.º 7
0
    def run(self, out_dir, location_search, swipe_count=5, collect=''):
        """
        Run single Gmaps workload.

        :param out_dir: Path to experiment directory where to store results.
        :type out_dir: str

        :param location_search: Search string to be used in GMaps
        :type location_search: str

        :param swipe_count: Number of sets of (left, right, up, down) swipes to do
        :type swipe_count: int

        :param collect: Specifies what to collect. Possible values:
            - 'energy'
            - 'systrace'
            - 'ftrace'
            - any combination of the above
        :type collect: list(str)
        """

        # Keep track of mandatory parameters
        self.out_dir = out_dir
        self.collect = collect

        # Set min brightness
        Screen.set_brightness(self._target, auto=False, percent=0)
        # Unlock device screen (assume no password required)
        Screen.unlock(self._target)

        # Use the monkey tool to start GMaps
        # This allows to subsequently set the screen orientation to LANDSCAPE
        # and to reset the frame statistics.
        System.monkey(self._target, self.package)

        # Force screen in PORTRAIT  mode
        Screen.set_orientation(self._target, portrait=True)

        System.gfxinfo_reset(self._target, self.package)
        sleep(1)

        # Start GMaps on the target device
        loc_url = 'geo:0,0?q='
        loc_url += '+'.join(location_search.split())
        System.start_action(self._target, self.action, loc_url)
        # Allow the activity to start
        sleep(1)

        script = TargetScript(self._te, "gmaps_swiper.sh")
        self._log.debug('Accumulating commands')

        for i in range(swipe_count):
            System.hswipe(script, 20, 80, 100, True)
            script.append('sleep 1')
            System.hswipe(script, 20, 80, 100, False)
            script.append('sleep 1')
            System.vswipe(script, 40, 60, 100, True)
            script.append('sleep 1')
            System.vswipe(script, 40, 60, 100, False)
            script.append('sleep 1')

        self._log.debug('Accumulation done')

        # Push script to the target
        script.push()

        self._log.info('Opening GMaps to [%s]', loc_url)
        # Let GMaps zoom in on the location
        sleep(2)

        self.tracingStart()

        self._log.info('Launching target script')
        script.run()
        self._log.info('Target script ended')

        self.tracingStop()

        # Get frame stats
        self.db_file = os.path.join(out_dir, "framestats.txt")
        System.gfxinfo_get(self._target, self.package, self.db_file)

        # Close the app without clearing the local data to
        # avoid the dialog to select the account at next start
        System.force_stop(self._target, self.package, clear=False)

        # Go back to home screen
        System.home(self._target)

        # Set brightness back to auto
        Screen.set_brightness(self._target, auto=True)

        # Switch back to screen auto rotation
        Screen.set_orientation(self._target, auto=True)