コード例 #1
0
def MeasurePowerOnce(browser, logfile, duration, delay, resolution, url,
                     extra_browser_args):
    logging.debug("Logging into " + logfile)
    user_data_dir = tempfile.mkdtemp()
    browser_proc = LaunchBrowser(browser, user_data_dir, url,
                                 extra_browser_args)
    ipg_utils.RunIPG(duration + delay, resolution, logfile)
    if browser == 'edge':
        # Because Edge is launched with |shell| set to true, browser_proc isn't
        # the Edge process, so the following is used to kill all Edge processes
        # in the system, including ones not launched through this script.
        subprocess.call("taskkill /F /IM MicrosoftEdge.exe /T")
    else:
        browser_proc.kill()
        for _ in range(100):
            if browser_proc.poll() is not None:
                break
            logging.debug("Waiting for browser to exit")
            time.sleep(0.05)
    try:
        shutil.rmtree(user_data_dir)
    except Exception as err:
        logging.warning("Failed to remove temporary folder: " + user_data_dir)
        logging.warning(
            "Please kill browser and remove it manually to avoid leak")
        logging.debug(err)
    results = ipg_utils.AnalyzeIPGLogFile(logfile, delay)
    return results
コード例 #2
0
def MeasurePowerOnce(browser, logfile, duration, delay, resolution, url,
                     extra_browser_args):
    logging.debug("Logging into " + logfile)
    user_data_dir = tempfile.mkdtemp()
    browser_proc = LaunchBrowser(browser, user_data_dir, url,
                                 extra_browser_args)
    ipg_utils.RunIPG(duration + delay, resolution, logfile)
    if browser == 'edge':
        subprocess.call("taskkill /F /IM MicrosoftEdge.exe /T")
    else:
        browser_proc.kill()
        for _ in range(100):
            if browser_proc.poll() is not None:
                break
            logging.debug("Waiting for browser to exit")
            time.sleep(0.05)
    try:
        shutil.rmtree(user_data_dir)
    except Exception as err:
        logging.warning("Failed to remove temporary folder: " + user_data_dir)
        logging.warning(
            "Please kill browser and remove it manually to avoid leak")
        logging.debug(err)
    results = ipg_utils.AnalyzeIPGLogFile(logfile, delay)
    return results
コード例 #3
0
    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
コード例 #4
0
 def _MeasurePowerWithIPG(bypass_ipg):
   total_time = _POWER_MEASUREMENT_DURATION + _POWER_MEASUREMENT_DELAY
   if bypass_ipg:
     logging.info("Bypassing Intel Power Gadget")
     time.sleep(total_time)
     return {}
   logfile = None  # Use the default path
   ipg_utils.RunIPG(total_time, _POWER_MEASUREMENT_RESOLUTION, logfile)
   results = ipg_utils.AnalyzeIPGLogFile(logfile, _POWER_MEASUREMENT_DELAY)
   return results
コード例 #5
0
 def _RunTest_Basic(self, test_path, params):
     logfile = None  # Use the default path
     ipg_utils.RunIPG(
         _POWER_MEASUREMENT_DURATION + _POWER_MEASUREMENT_DELAY,
         _POWER_MEASUREMENT_RESOLUTION, logfile)
     results = ipg_utils.AnalyzeIPGLogFile(logfile,
                                           _POWER_MEASUREMENT_DELAY)
     # TODO(zmo): output in a way that the results can be tracked at
     # chromeperf.appspot.com.
     print "Results: ", results
コード例 #6
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']
        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))
コード例 #7
0
 def _MeasurePowerWithIPG(bypass_ipg):
   total_time = _POWER_MEASUREMENT_DURATION + _POWER_MEASUREMENT_DELAY
   if bypass_ipg:
     logging.info("Bypassing Intel Power Gadget")
     time.sleep(total_time)
     return
   logfile = None # Use the default path
   ipg_utils.RunIPG(total_time, _POWER_MEASUREMENT_RESOLUTION, logfile)
   results = ipg_utils.AnalyzeIPGLogFile(logfile, _POWER_MEASUREMENT_DELAY)
   # TODO(zmo): output in a way that the results can be tracked at
   # chromeperf.appspot.com.
   logging.info("Results: %s", str(results))
    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
コード例 #9
0
def MeasurePowerOnce(browser, logfile, duration, delay, resolution, url,
                     fullscreen, extra_browser_args):
  logging.debug("Logging into " + logfile)
  user_data_dir = tempfile.mkdtemp()

  driver = CreateWebDriver(browser, user_data_dir, url, fullscreen,
                           extra_browser_args)
  ipg_utils.RunIPG(duration + delay, resolution, logfile)
  driver.quit()

  try:
    shutil.rmtree(user_data_dir)
  except Exception as err:
    logging.warning("Failed to remove temporary folder: " + user_data_dir)
    logging.warning("Please kill browser and remove it manually to avoid leak")
    logging.debug(err)
  results = ipg_utils.AnalyzeIPGLogFile(logfile, delay)
  return results
コード例 #10
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
コード例 #11
0
    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