def RunActualGpuTest(self, test_path, *args):
        ipg_path = ipg_utils.LocateIPG()
        if not ipg_path:
            self.fail("Fail to locate Intel Power Gadget")

        repeat = args[0]
        outliers = args[1]
        fullscreen = args[2]
        ipg_logdir = args[3]
        ipg_duration = args[4]
        ipg_delay = args[5]
        ipg_resolution = args[6]

        print ""
        print "Total iterations: ", repeat
        logfiles = []
        for iteration in range(repeat):
            run_label = "Iteration_%d" % iteration
            print run_label
            if test_path:
                self.tab.action_runner.Navigate(test_path, fullscreen_script)
                self.tab.WaitForDocumentReadyStateToBeComplete()
                self.tab.action_runner.ExecuteJavaScript('setupVideoElement()')
                self.tab.action_runner.WaitForJavaScriptCondition(
                    'isVideoPlaying()', timeout=10)

            if fullscreen:
                # TODO(zmo): Switch to use click instead of tap once Telemetry's click
                # is implemented through DevTools.
                self.tab.action_runner.TapElement(
                    element_function=('locateButton("%s")' % test_path))

            logfile = None
            if ipg_logdir:
                if not os.path.isdir(ipg_logdir):
                    self.fail("Folder " + ipg_logdir + " doesn't exist")
                logfile = ipg_utils.GenerateIPGLogFilename(log_dir=ipg_logdir,
                                                           timestamp=True)
            ipg_utils.RunIPG(ipg_duration + ipg_delay, ipg_resolution, logfile)
            logfiles.append(logfile)

            if repeat > 1 and iteration < repeat - 1:
                self.StopBrowser()
                self.StartBrowser()

        if repeat == 1:
            results = ipg_utils.AnalyzeIPGLogFile(logfiles[0], ipg_delay)
            print "Results: ", results
        else:
            json_path = None
            if ipg_logdir:
                json_path = os.path.join(ipg_logdir, "output.json")
                print "Results saved in ", json_path

            summary = ipg_utils.ProcessResultsFromMultipleIPGRuns(
                logfiles, ipg_delay, outliers, json_path)
            print 'Summary: ', summary
    def _RunTest_URL(self, test_path, params):
        repeat = params['repeat']
        outliers = params['outliers']
        fullscreen = params['fullscreen']
        underlay = params['underlay']
        ipg_logdir = params['logdir']
        ipg_duration = params['duration']
        ipg_delay = params['delay']
        ipg_resolution = params['resolution']
        bypass_ipg = params['bypass_ipg']

        if repeat > 1:
            logging.info("Total iterations: %d", repeat)
        logfiles = []
        for iteration in range(repeat):
            if repeat > 1:
                logging.info("Iteration %d", iteration)
            self.tab.action_runner.Navigate(test_path, _VIDEO_TEST_SCRIPT)
            self.tab.WaitForDocumentReadyStateToBeComplete()
            self._SetupVideo(fullscreen=fullscreen, underlay=underlay)

            if bypass_ipg:
                logging.info("Bypassing Intel Power Gadget")
                time.sleep(ipg_duration + ipg_delay)
            else:
                logfile = None
                if ipg_logdir:
                    if not os.path.isdir(ipg_logdir):
                        self.fail("Folder " + ipg_logdir + " doesn't exist")
                    logfile = ipg_utils.GenerateIPGLogFilename(
                        log_dir=ipg_logdir, timestamp=True)
                ipg_utils.RunIPG(ipg_duration + ipg_delay, ipg_resolution,
                                 logfile)
                logfiles.append(logfile)

            if repeat > 1 and iteration < repeat - 1:
                self.StopBrowser()
                self.StartBrowser()

        if bypass_ipg:
            return

        if repeat == 1:
            results = ipg_utils.AnalyzeIPGLogFile(logfiles[0], ipg_delay)
            logging.info("Results: %s", str(results))
        else:
            json_path = None
            if ipg_logdir:
                json_path = os.path.join(ipg_logdir, "output.json")
                print "Results saved in ", json_path

            summary = ipg_utils.ProcessResultsFromMultipleIPGRuns(
                logfiles, ipg_delay, outliers, json_path)
            logging.info("Summary: %s", str(summary))
    def RunActualGpuTest(self, test_path, *args):
        ipg_path = ipg_utils.LocateIPG()
        if not ipg_path:
            self.fail("Fail to locate Intel Power Gadget")

        repeat = args[0]
        outliers = args[1]
        fullscreen = args[2]
        ipg_logdir = args[3]
        ipg_duration = args[4]
        ipg_delay = args[5]
        ipg_resolution = args[6]

        print ""
        print "Total iterations: ", repeat
        logfiles = []
        for iteration in range(repeat):
            run_label = "Iteration_%d" % iteration
            print run_label
            if test_path:
                self.tab.action_runner.Navigate(test_path)

            if fullscreen:
                # TODO(zmo): implement fullscreen mode.
                pass

            logfile = None
            if ipg_logdir:
                if not os.path.isdir(ipg_logdir):
                    self.fail("Folder " + ipg_logdir + " doesn't exist")
                logfile = ipg_utils.GenerateIPGLogFilename(log_dir=ipg_logdir,
                                                           timestamp=True)
            ipg_utils.RunIPG(ipg_duration + ipg_delay, ipg_resolution, logfile)
            logfiles.append(logfile)

            if repeat > 1 and iteration < repeat - 1:
                self.StopBrowser()
                self.StartBrowser()

        if repeat == 1:
            results = ipg_utils.AnalyzeIPGLogFile(logfiles[0], ipg_delay)
            print "Results: ", results
        else:
            json_path = None
            if ipg_logdir:
                json_path = os.path.join(ipg_logdir, "output.json")
                print "Results saved in ", json_path

            summary = ipg_utils.ProcessResultsFromMultipleIPGRuns(
                logfiles, ipg_delay, outliers, json_path)
            print 'Summary: ', summary
Example #4
0
    def _RunTest_URL(self, test_path, params):
        repeat = params['repeat']
        outliers = params['outliers']
        fullscreen = params['fullscreen']
        underlay = params['underlay']
        ipg_logdir = params['logdir']
        ipg_duration = params['duration']
        ipg_delay = params['delay']
        ipg_resolution = params['resolution']

        print ""
        print "Total iterations: ", repeat
        logfiles = []
        for iteration in range(repeat):
            run_label = "Iteration_%d" % iteration
            print run_label
            if test_path:
                self.tab.action_runner.Navigate(test_path, _FULLSCREEN_SCRIPT)
                self.tab.WaitForDocumentReadyStateToBeComplete()
                code = "setupVideoElement(%s)" % ("true"
                                                  if underlay else "false")
                if not self.tab.action_runner.EvaluateJavaScript(code):
                    # autoplay doesn't work for vimeo.
                    # action_runner.PlayMedia doesn't work for vimeo.
                    self.tab.action_runner.ClickElement(
                        element_function=('locateElement("video")'))

            if fullscreen:
                if self.tab.action_runner.EvaluateJavaScript(
                        'locateFullscreenButton() == null'):
                    self.fail(
                        "Fullscreen button not located, --fullscreen won't work"
                    )
                self.tab.action_runner.ClickElement(
                    element_function=('locateFullscreenButton()'))

            logfile = None
            if ipg_logdir:
                if not os.path.isdir(ipg_logdir):
                    self.fail("Folder " + ipg_logdir + " doesn't exist")
                logfile = ipg_utils.GenerateIPGLogFilename(log_dir=ipg_logdir,
                                                           timestamp=True)
            ipg_utils.RunIPG(ipg_duration + ipg_delay, ipg_resolution, logfile)
            logfiles.append(logfile)

            if repeat > 1 and iteration < repeat - 1:
                self.StopBrowser()
                self.StartBrowser()

        if repeat == 1:
            results = ipg_utils.AnalyzeIPGLogFile(logfiles[0], ipg_delay)
            print "Results: ", results
        else:
            json_path = None
            if ipg_logdir:
                json_path = os.path.join(ipg_logdir, "output.json")
                print "Results saved in ", json_path

            summary = ipg_utils.ProcessResultsFromMultipleIPGRuns(
                logfiles, ipg_delay, outliers, json_path)
            print 'Summary: ', summary
    def RunActualGpuTest(self, test_path, *args):
        ipg_path = ipg_utils.LocateIPG()
        if not ipg_path:
            self.fail("Fail to locate Intel Power Gadget")

        repeat = args[0]
        outliers = args[1]
        fullscreen = args[2]
        underlay = args[3]
        ipg_logdir = args[4]
        ipg_duration = args[5]
        ipg_delay = args[6]
        ipg_resolution = args[7]

        print ""
        print "Total iterations: ", repeat
        logfiles = []
        for iteration in range(repeat):
            run_label = "Iteration_%d" % iteration
            print run_label
            if test_path:
                self.tab.action_runner.Navigate(test_path, fullscreen_script)
                self.tab.WaitForDocumentReadyStateToBeComplete()
                code = "setupVideoElement(%s)" % ("true"
                                                  if underlay else "false")
                if not self.tab.action_runner.EvaluateJavaScript(code):
                    # autoplay doesn't work for vimeo.
                    # action_runner.PlayMedia doesn't work for vimeo.
                    self.tab.action_runner.TapElement(
                        element_function=('locateElement("video")'))
                self.tab.action_runner.WaitForJavaScriptCondition(
                    'isVideoPlaying()', timeout=10)

            if fullscreen:
                if self.tab.action_runner.EvaluateJavaScript(
                        'locateFullscreenButton() == null'):
                    self.fail(
                        "Fullscreen button not located, --fullscreen won't work"
                    )
                self.tab.action_runner.TapElement(
                    element_function=('locateFullscreenButton()'))

            logfile = None
            if ipg_logdir:
                if not os.path.isdir(ipg_logdir):
                    self.fail("Folder " + ipg_logdir + " doesn't exist")
                logfile = ipg_utils.GenerateIPGLogFilename(log_dir=ipg_logdir,
                                                           timestamp=True)
            ipg_utils.RunIPG(ipg_duration + ipg_delay, ipg_resolution, logfile)
            logfiles.append(logfile)

            if repeat > 1 and iteration < repeat - 1:
                self.StopBrowser()
                self.StartBrowser()

        if repeat == 1:
            results = ipg_utils.AnalyzeIPGLogFile(logfiles[0], ipg_delay)
            print "Results: ", results
        else:
            json_path = None
            if ipg_logdir:
                json_path = os.path.join(ipg_logdir, "output.json")
                print "Results saved in ", json_path

            summary = ipg_utils.ProcessResultsFromMultipleIPGRuns(
                logfiles, ipg_delay, outliers, json_path)
            print 'Summary: ', summary