def Measure(self, platform, results): # Reads results from |RESULTS_FILE| on target and adds to |results|. jsonResults = json.loads( self._device.ReadFile( perf_test_utils.GetConfig(self._device)['RESULTS_FILE'])) for test in jsonResults: results.AddMeasurement(test, 'ms', jsonResults[test])
def main(): device = perf_test_utils.NativeDevice() # Start HTTP server. http_server_doc_root = perf_test_utils.GenerateHttpTestResources() config_file = tempfile.NamedTemporaryFile() http_server = lighttpd_server.LighttpdServer( http_server_doc_root, port=perf_test_utils.HTTP_PORT, base_config_path=config_file.name) perf_test_utils.GenerateLighttpdConfig(config_file, http_server_doc_root, http_server) assert http_server.StartupHttpServer() config_file.close() # Start QUIC server. quic_server_doc_root = perf_test_utils.GenerateQuicTestResources(device) quic_server = perf_test_utils.QuicServer(quic_server_doc_root) quic_server.StartupQuicServer(device) # Run test os.environ['LD_LIBRARY_PATH'] = perf_test_utils.BUILD_DIR device.RunShellCommand([ os.path.join(perf_test_utils.BUILD_DIR, 'cronet_native_perf_test'), json.dumps(perf_test_utils.GetConfig(device)) ], check_return=True) # Shutdown. quic_server.ShutdownQuicServer() shutil.rmtree(quic_server_doc_root) http_server.ShutdownHttpServer() shutil.rmtree(http_server_doc_root)
def __init__(self, device): self._device = device config = perf_test_utils.GetConfig(device) device.RemovePath(config['DONE_FILE'], force=True) self.url ='http://dummy/?'+urllib.urlencode(config) start_intent = intent.Intent( package=perf_test_utils.APP_PACKAGE, activity=perf_test_utils.APP_ACTIVITY, action=perf_test_utils.APP_ACTION, # |config| maps from configuration value names to the configured values. # |config| is encoded as URL parameter names and values and passed to # the Cronet perf test app via the Intent data field. data=self.url, extras=None, category=None) super(CronetPerfTestAndroidStory, self).__init__( start_intent, name='CronetPerfTest', # No reason to wait for app; Run() will wait for results. By default # StartActivity will timeout waiting for CronetPerfTest, so override # |is_app_ready_predicate| to not wait. is_app_ready_predicate=lambda app: True)
def Run(self, shared_user_story_state): while not self._device.FileExists( perf_test_utils.GetConfig(self._device)['DONE_FILE']): time.sleep(1.0)