diff options
author | Luis Lozano <llozano@chromium.org> | 2015-12-15 13:49:30 -0800 |
---|---|---|
committer | Luis Lozano <llozano@chromium.org> | 2015-12-16 17:36:06 +0000 |
commit | f2a3ef46f75d2196a93d3ed27f4d1fcf22b54fbe (patch) | |
tree | 185d243c7eed7c7a0db6f0e640746cadc1479ea9 /cwp | |
parent | 2a66f70fef907c1cb15229cb58e5129cb620ac98 (diff) | |
download | toolchain-utils-f2a3ef46f75d2196a93d3ed27f4d1fcf22b54fbe.tar.gz |
Run pyformat on all the toolchain-utils files.
This gets rid of a lot of lint issues.
Ran by doing this:
for f in *.py; do echo -n "$f " ; if [ -x $f ]; then pyformat -i
--remove_trailing_comma --yapf --force_quote_type=double $f ; else
pyformat -i --remove_shebang --remove_trailing_comma --yapf
--force_quote_type=double $f ; fi ; done
BUG=chromium:567921
TEST=Ran simple crosperf run.
Change-Id: I59778835fdaa5f706d2e1765924389f9e97433d1
Reviewed-on: https://chrome-internal-review.googlesource.com/242031
Reviewed-by: Luis Lozano <llozano@chromium.org>
Commit-Queue: Luis Lozano <llozano@chromium.org>
Tested-by: Luis Lozano <llozano@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@google.com>
Diffstat (limited to 'cwp')
-rwxr-xr-x | cwp/bartlett/server.py | 53 | ||||
-rw-r--r-- | cwp/bartlett/test/server_tester.py | 35 | ||||
-rw-r--r-- | cwp/interpreter/app_engine_pull.py | 122 | ||||
-rw-r--r-- | cwp/interpreter/symbolizer.py | 46 | ||||
-rw-r--r-- | cwp/performance/experiment_gen.py | 66 |
5 files changed, 175 insertions, 147 deletions
diff --git a/cwp/bartlett/server.py b/cwp/bartlett/server.py index c61f3444..f6b35361 100755 --- a/cwp/bartlett/server.py +++ b/cwp/bartlett/server.py @@ -41,19 +41,19 @@ logging.getLogger().setLevel(logging.DEBUG) class FileEntry(db.Model): - profile_data = db.BlobProperty() # The profile data - date = db.DateTimeProperty(auto_now_add=True) # Date it was uploaded - data_md5 = db.ByteStringProperty() # md5 of the profile data - board = db.StringProperty() # board arch - chromeos_version = db.StringProperty() # ChromeOS version + profile_data = db.BlobProperty() # The profile data + date = db.DateTimeProperty(auto_now_add=True) # Date it was uploaded + data_md5 = db.ByteStringProperty() # md5 of the profile data + board = db.StringProperty() # board arch + chromeos_version = db.StringProperty() # ChromeOS version class MainPage(webapp.RequestHandler): """Main page only used as the form template, not actually displayed.""" - def get(self, response=""): # pylint: disable-msg=C6409 + def get(self, response=''): # pylint: disable-msg=C6409 if response: - self.response.out.write("<html><body>") + self.response.out.write('<html><body>') self.response.out.write("""<br> <form action="/upload" enctype="multipart/form-data" method="post"> <div><label>Profile Data:</label></div> @@ -74,11 +74,11 @@ class Upload(webapp.RequestHandler): def post(self): # pylint: disable-msg=C6409 """Takes input based on the main page's form.""" getfile = FileEntry() - f1 = self.request.get("profile_data") + f1 = self.request.get('profile_data') getfile.profile_data = db.Blob(f1) getfile.data_md5 = md5.new(f1).hexdigest() - getfile.board = self.request.get("board") - getfile.chromeos_version = self.request.get("chromeos_version") + getfile.board = self.request.get('board') + getfile.chromeos_version = self.request.get('chromeos_version') getfile.put() self.response.out.write(getfile.key()) #self.redirect('/') @@ -101,15 +101,15 @@ class ListAll(webapp.RequestHandler): def get(self): # pylint: disable-msg=C6409 """Displays all information in FileEntry, ~ delimited.""" if Authenticate(self): - query_str = "SELECT * FROM FileEntry ORDER BY date ASC" + query_str = 'SELECT * FROM FileEntry ORDER BY date ASC' query = db.GqlQuery(query_str) - delimiter = "~" + delimiter = '~' for item in query: - display_list = [item.key(), item.date, item.data_md5, - item.board, item.chromeos_version] + display_list = [item.key(), item.date, item.data_md5, item.board, + item.chromeos_version] str_list = [cgi.escape(str(i)) for i in display_list] - self.response.out.write(delimiter.join(str_list)+"</br>") + self.response.out.write(delimiter.join(str_list) + '</br>') class DelEntries(webapp.RequestHandler): @@ -129,24 +129,25 @@ def Authenticate(webpage): user = users.get_current_user() if user is None: webpage.redirect(users.create_login_url(webpage.request.uri)) - elif user.email().endswith("@google.com"): + elif user.email().endswith('@google.com'): return True else: - webpage.response.out.write("Not Authenticated") + webpage.response.out.write('Not Authenticated') return False def main(): - application = webapp.WSGIApplication([ - ("/", MainPage), - ("/upload", Upload), - ("/serve/([^/]+)?", ServeHandler), - ("/serve", ListAll), - ("/del/([^/]+)?", DelEntries), - ], debug=False) + application = webapp.WSGIApplication( + [ + ('/', MainPage), + ('/upload', Upload), + ('/serve/([^/]+)?', ServeHandler), + ('/serve', ListAll), + ('/del/([^/]+)?', DelEntries), + ], + debug=False) run_wsgi_app(application) -if __name__ == "__main__": +if __name__ == '__main__': main() - diff --git a/cwp/bartlett/test/server_tester.py b/cwp/bartlett/test/server_tester.py index 27889651..585da43a 100644 --- a/cwp/bartlett/test/server_tester.py +++ b/cwp/bartlett/test/server_tester.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # Copyright 2012 Google Inc. All Rights Reserved. # Author: mrdmnd@ (Matt Redmond) """A unit test for sending data to Bartlett. Requires poster module.""" @@ -15,10 +14,9 @@ import urllib2 from poster.encode import multipart_encode from poster.streaminghttp import register_openers - -SERVER_DIR = "../." -SERVER_URL = "http://localhost:8080/" -GET = "_ah/login?email=googler@google.com&action=Login&continue=%s" +SERVER_DIR = '../.' +SERVER_URL = 'http://localhost:8080/' +GET = '_ah/login?email=googler@google.com&action=Login&continue=%s' AUTH_URL = SERVER_URL + GET @@ -51,44 +49,46 @@ class ServerTest(unittest.TestCase): def _testUpload(self): # pylint: disable-msg=C6409 register_openers() - data = {"profile_data": self.profile_data, - "board": "x86-zgb", - "chromeos_version": "2409.0.2012_06_08_1114"} + data = {'profile_data': self.profile_data, + 'board': 'x86-zgb', + 'chromeos_version': '2409.0.2012_06_08_1114'} datagen, headers = multipart_encode(data) - request = urllib2.Request(SERVER_URL + "upload", datagen, headers) + request = urllib2.Request(SERVER_URL + 'upload', datagen, headers) response = urllib2.urlopen(request).read() self.assertTrue(response) return response def _testListAll(self): # pylint: disable-msg=C6409 - request = urllib2.Request(AUTH_URL % (SERVER_URL + "serve")) + request = urllib2.Request(AUTH_URL % (SERVER_URL + 'serve')) response = self.opener.open(request).read() self.assertTrue(response) def _testServeKey(self, key): # pylint: disable-msg=C6409 - request = urllib2.Request(AUTH_URL % (SERVER_URL + "serve/" + key)) + request = urllib2.Request(AUTH_URL % (SERVER_URL + 'serve/' + key)) response = self.opener.open(request).read() self.assertTrue(response) def _testDelKey(self, key): # pylint: disable-msg=C6409 # There is no response to a delete request. # We will check the listAll page to ensure there is no data. - request = urllib2.Request(AUTH_URL % (SERVER_URL + "del/" + key)) + request = urllib2.Request(AUTH_URL % (SERVER_URL + 'del/' + key)) response = self.opener.open(request).read() - request = urllib2.Request(AUTH_URL % (SERVER_URL + "serve")) + request = urllib2.Request(AUTH_URL % (SERVER_URL + 'serve')) response = self.opener.open(request).read() self.assertFalse(response) def LaunchLocalServer(): """Launch and store an authentication cookie with a local server.""" - proc = subprocess.Popen(["dev_appserver.py", "--clear_datastore", SERVER_DIR], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) + proc = subprocess.Popen( + ['dev_appserver.py', '--clear_datastore', SERVER_DIR], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) # Wait for server to come up while True: time.sleep(1) try: - request = urllib2.Request(SERVER_URL + "serve") + request = urllib2.Request(SERVER_URL + 'serve') response = urllib2.urlopen(request).read() if response: break @@ -97,6 +97,5 @@ def LaunchLocalServer(): return proc -if __name__ == "__main__": +if __name__ == '__main__': unittest.main() - diff --git a/cwp/interpreter/app_engine_pull.py b/cwp/interpreter/app_engine_pull.py index 65f67940..d092e2a3 100644 --- a/cwp/interpreter/app_engine_pull.py +++ b/cwp/interpreter/app_engine_pull.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # Copyright 2012 Google Inc. All Rights Reserved. # Author: mrdmnd@ (Matt Redmond) """A client to pull data from Bartlett. @@ -23,9 +22,9 @@ import os import urllib import urllib2 -SERVER_NAME = "http://chromeoswideprofiling.appspot.com" -APP_NAME = "chromeoswideprofiling" -DELIMITER = "~" +SERVER_NAME = 'http://chromeoswideprofiling.appspot.com' +APP_NAME = 'chromeoswideprofiling' +DELIMITER = '~' def Authenticate(server_name): @@ -38,33 +37,33 @@ def Authenticate(server_name): to grab other pages. """ - if server_name.endswith("/"): - server_name = server_name.rstrip("/") + if server_name.endswith('/'): + server_name = server_name.rstrip('/') # Grab username and password from user through stdin. - username = raw_input("Email (must be @google.com account): ") - password = getpass.getpass("Password: ") + username = raw_input('Email (must be @google.com account): ') + password = getpass.getpass('Password: ') # Use a cookie to authenticate with GAE. cookiejar = cookielib.LWPCookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar)) urllib2.install_opener(opener) # Get an AuthToken from Google accounts service. - auth_uri = "https://www.google.com/accounts/ClientLogin" - authreq_data = urllib.urlencode({"Email": username, - "Passwd": password, - "service": "ah", - "source": APP_NAME, - "accountType": "HOSTED_OR_GOOGLE"}) + auth_uri = 'https://www.google.com/accounts/ClientLogin' + authreq_data = urllib.urlencode({'Email': username, + 'Passwd': password, + 'service': 'ah', + 'source': APP_NAME, + 'accountType': 'HOSTED_OR_GOOGLE'}) auth_req = urllib2.Request(auth_uri, data=authreq_data) try: auth_resp = urllib2.urlopen(auth_req) except urllib2.URLError: - print "Error logging in to Google accounts service." + print 'Error logging in to Google accounts service.' return None body = auth_resp.read() # Auth response contains several fields. # We care about the part after Auth= - auth_resp_dict = dict(x.split("=") for x in body.split("\n") if x) - authtoken = auth_resp_dict["Auth"] + auth_resp_dict = dict(x.split('=') for x in body.split('\n') if x) + authtoken = auth_resp_dict['Auth'] return authtoken @@ -81,32 +80,32 @@ def DownloadSamples(server_name, authtoken, output_dir, start, stop): None """ - if server_name.endswith("/"): - server_name = server_name.rstrip("/") + if server_name.endswith('/'): + server_name = server_name.rstrip('/') serve_page_string = _GetServePage(server_name, authtoken) if serve_page_string is None: - print "Error getting /serve page." + print 'Error getting /serve page.' return - sample_list = serve_page_string.split("</br>") - print "Will download:" + sample_list = serve_page_string.split('</br>') + print 'Will download:' sample_list_subset = sample_list[start:stop] for sample in sample_list_subset: print sample for sample in sample_list_subset: - assert sample, "Sample should be valid." + assert sample, 'Sample should be valid.' sample_info = [s.strip() for s in sample.split(DELIMITER)] key = sample_info[0] time = sample_info[1] - time = time.replace(" ", "_") # No space between date and time. + time = time.replace(' ', '_') # No space between date and time. # sample_md5 = sample_info[2] board = sample_info[3] version = sample_info[4] # Put a compressed copy of the samples in output directory. - _DownloadSampleFromServer(server_name, authtoken, key, time, board, - version, output_dir) + _DownloadSampleFromServer(server_name, authtoken, key, time, board, version, + output_dir) _UncompressSample(key, time, board, version, output_dir) @@ -124,8 +123,8 @@ def _BuildFilenameFromParams(key, time, board, version): return filename -def _DownloadSampleFromServer(server_name, authtoken, key, time, board, - version, output_dir): +def _DownloadSampleFromServer(server_name, authtoken, key, time, board, version, + output_dir): """Downloads sample_$(samplekey).gz to current dir. Args: server_name: (string) URL that the app engine code is living on. @@ -139,18 +138,18 @@ def _DownloadSampleFromServer(server_name, authtoken, key, time, board, None """ filename = _BuildFilenameFromParams(key, time, board, version) - compressed_filename = filename+".gz" + compressed_filename = filename + '.gz' if os.path.exists(os.path.join(output_dir, filename)): - print "Already downloaded %s, skipping." % filename + print 'Already downloaded %s, skipping.' % filename return - serv_uri = server_name + "/serve/" + key - serv_args = {"continue": serv_uri, "auth": authtoken} - full_serv_uri = server_name + "/_ah/login?%s" % urllib.urlencode(serv_args) + serv_uri = server_name + '/serve/' + key + serv_args = {'continue': serv_uri, 'auth': authtoken} + full_serv_uri = server_name + '/_ah/login?%s' % urllib.urlencode(serv_args) serv_req = urllib2.Request(full_serv_uri) serv_resp = urllib2.urlopen(serv_req) - f = open(os.path.join(output_dir, compressed_filename), "w+") + f = open(os.path.join(output_dir, compressed_filename), 'w+') f.write(serv_resp.read()) f.close() @@ -167,14 +166,14 @@ def _UncompressSample(key, time, board, version, output_dir): None """ filename = _BuildFilenameFromParams(key, time, board, version) - compressed_filename = filename+".gz" + compressed_filename = filename + '.gz' if os.path.exists(os.path.join(output_dir, filename)): - print "Already decompressed %s, skipping." % filename + print 'Already decompressed %s, skipping.' % filename return - out_file = open(os.path.join(output_dir, filename), "wb") - in_file = gzip.open(os.path.join(output_dir, compressed_filename), "rb") + out_file = open(os.path.join(output_dir, filename), 'wb') + in_file = gzip.open(os.path.join(output_dir, compressed_filename), 'rb') out_file.write(in_file.read()) in_file.close() out_file.close() @@ -192,9 +191,9 @@ def _DeleteSampleFromServer(server_name, authtoken, key): None """ - serv_uri = server_name + "/del/" + key - serv_args = {"continue": serv_uri, "auth": authtoken} - full_serv_uri = server_name + "/_ah/login?%s" % urllib.urlencode(serv_args) + serv_uri = server_name + '/del/' + key + serv_args = {'continue': serv_uri, 'auth': authtoken} + full_serv_uri = server_name + '/_ah/login?%s' % urllib.urlencode(serv_args) serv_req = urllib2.Request(full_serv_uri) urllib2.urlopen(serv_req) @@ -208,9 +207,9 @@ def _GetServePage(server_name, authtoken): The text of the /serve page (including HTML tags) """ - serv_uri = server_name + "/serve" - serv_args = {"continue": serv_uri, "auth": authtoken} - full_serv_uri = server_name + "/_ah/login?%s" % urllib.urlencode(serv_args) + serv_uri = server_name + '/serve' + serv_args = {'continue': serv_uri, 'auth': authtoken} + full_serv_uri = server_name + '/_ah/login?%s' % urllib.urlencode(serv_args) serv_req = urllib2.Request(full_serv_uri) serv_resp = urllib2.urlopen(serv_req) return serv_resp.read() @@ -218,28 +217,37 @@ def _GetServePage(server_name, authtoken): def main(): parser = optparse.OptionParser() - parser.add_option("--output_dir", dest="output_dir", action="store", - help="Path to output perf data files.") - parser.add_option("--start", dest="start_ind", action="store", - default=0, help="Start index.") - parser.add_option("--stop", dest="stop_ind", action="store", - default=-1, help="Stop index.") + parser.add_option('--output_dir', + dest='output_dir', + action='store', + help='Path to output perf data files.') + parser.add_option('--start', + dest='start_ind', + action='store', + default=0, + help='Start index.') + parser.add_option('--stop', + dest='stop_ind', + action='store', + default=-1, + help='Stop index.') options = parser.parse_args()[0] if not options.output_dir: - print "Must specify --output_dir." + print 'Must specify --output_dir.' return 1 if not os.path.exists(options.output_dir): - print "Specified output_dir does not exist." + print 'Specified output_dir does not exist.' return 1 authtoken = Authenticate(SERVER_NAME) if not authtoken: - print "Could not obtain authtoken, exiting." + print 'Could not obtain authtoken, exiting.' return 1 - DownloadSamples(SERVER_NAME, authtoken, options.output_dir, - options.start_ind, options.stop_ind) - print "Downloaded samples." + DownloadSamples(SERVER_NAME, authtoken, options.output_dir, options.start_ind, + options.stop_ind) + print 'Downloaded samples.' return 0 -if __name__ == "__main__": + +if __name__ == '__main__': exit(main()) diff --git a/cwp/interpreter/symbolizer.py b/cwp/interpreter/symbolizer.py index 3e589538..902e319d 100644 --- a/cwp/interpreter/symbolizer.py +++ b/cwp/interpreter/symbolizer.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # Copyright 2012 Google Inc. All Rights Reserved. """A script that symbolizes perf.data files.""" import optparse @@ -9,19 +8,18 @@ from subprocess import PIPE from subprocess import Popen from utils import misc - -GSUTIL_CMD = "gsutil cp gs://chromeos-image-archive/%s-release/%s/debug.tgz %s" -TAR_CMD = "tar -zxvf %s -C %s" -PERF_BINARY = "/google/data/ro/projects/perf/perf" -VMLINUX_FLAG = " --vmlinux=/usr/lib/debug/boot/vmlinux" -PERF_CMD = PERF_BINARY +" report -i %s -n --symfs=%s" + VMLINUX_FLAG +GSUTIL_CMD = 'gsutil cp gs://chromeos-image-archive/%s-release/%s/debug.tgz %s' +TAR_CMD = 'tar -zxvf %s -C %s' +PERF_BINARY = '/google/data/ro/projects/perf/perf' +VMLINUX_FLAG = ' --vmlinux=/usr/lib/debug/boot/vmlinux' +PERF_CMD = PERF_BINARY + ' report -i %s -n --symfs=%s' + VMLINUX_FLAG def main(): parser = optparse.OptionParser() - parser.add_option("--in", dest="in_dir") - parser.add_option("--out", dest="out_dir") - parser.add_option("--cache", dest="cache") + parser.add_option('--in', dest='in_dir') + parser.add_option('--out', dest='out_dir') + parser.add_option('--cache', dest='cache') (opts, _) = parser.parse_args() if not _ValidateOpts(opts): return 1 @@ -31,7 +29,7 @@ def main(): _DownloadSymbols(filename, opts.cache) _PerfReport(filename, opts.in_dir, opts.out_dir, opts.cache) except: - print "Exception caught. Continuing..." + print 'Exception caught. Continuing...' return 0 @@ -54,14 +52,14 @@ def _ParseFilename(filename, canonical=False): If canonical is True, instead returns (database_key, board, canonical_vers) canonical_vers includes the revision string. """ - key, time, board, vers = filename.split("~") + key, time, board, vers = filename.split('~') if canonical: vers = misc.GetChromeOSVersionFromLSBVersion(vers) return (key, time, board, vers) def _FormReleaseDir(board, version): - return "%s-release~%s" % (board, version) + return '%s-release~%s' % (board, version) def _DownloadSymbols(filename, cache): @@ -70,27 +68,27 @@ def _DownloadSymbols(filename, cache): named like cache/$board-release~$canonical_vers/usr/lib/debug """ _, _, board, vers = _ParseFilename(filename, canonical=True) - tmp_suffix = ".tmp" + tmp_suffix = '.tmp' tarball_subdir = _FormReleaseDir(board, vers) tarball_dir = os.path.join(cache, tarball_subdir) - tarball_path = os.path.join(tarball_dir, "debug.tgz") + tarball_path = os.path.join(tarball_dir, 'debug.tgz') - symbol_subdir = os.path.join("usr", "lib") + symbol_subdir = os.path.join('usr', 'lib') symbol_dir = os.path.join(tarball_dir, symbol_subdir) if os.path.isdir(symbol_dir): - print "Symbol directory %s exists, skipping download." % symbol_dir + print 'Symbol directory %s exists, skipping download.' % symbol_dir return else: # First download using gsutil. if not os.path.isfile(tarball_path): download_cmd = GSUTIL_CMD % (board, vers, tarball_path + tmp_suffix) - print "Downloading symbols for %s" % filename + print 'Downloading symbols for %s' % filename print download_cmd ret = call(download_cmd.split()) if ret != 0: - print "gsutil returned non-zero error code: %s." % ret + print 'gsutil returned non-zero error code: %s.' % ret # Clean up the empty directory structures. os.remove(tarball_path + tmp_suffix) raise IOError @@ -100,11 +98,11 @@ def _DownloadSymbols(filename, cache): # Next, untar the tarball. os.makedirs(symbol_dir + tmp_suffix) extract_cmd = TAR_CMD % (tarball_path, symbol_dir + tmp_suffix) - print "Extracting symbols for %s" % filename + print 'Extracting symbols for %s' % filename print extract_cmd ret = call(extract_cmd.split()) if ret != 0: - print "tar returned non-zero code: %s." % ret + print 'tar returned non-zero code: %s.' % ret raise IOError shutil.move(symbol_dir + tmp_suffix, symbol_dir) os.remove(tarball_path) @@ -119,13 +117,13 @@ def _PerfReport(filename, in_dir, out_dir, cache): input_file = os.path.join(in_dir, filename) symfs = os.path.join(cache, symbol_cache_tld) report_cmd = PERF_CMD % (input_file, symfs) - print "Reporting." + print 'Reporting.' print report_cmd report_proc = Popen(report_cmd.split(), stdout=PIPE) - outfile = open(os.path.join(out_dir, filename), "w") + outfile = open(os.path.join(out_dir, filename), 'w') outfile.write(report_proc.stdout.read()) outfile.close() -if __name__ == "__main__": +if __name__ == '__main__': exit(main()) diff --git a/cwp/performance/experiment_gen.py b/cwp/performance/experiment_gen.py index 7752c11e..a12da2c5 100644 --- a/cwp/performance/experiment_gen.py +++ b/cwp/performance/experiment_gen.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # Copyright 2012 Google Inc. All Rights Reserved. """This script generates a crosperf overhead-testing experiment file for MoreJS. @@ -35,29 +34,53 @@ default { def main(): parser = optparse.OptionParser() - parser.add_option('--crosperf', dest='crosperf_root', action='store', + parser.add_option('--crosperf', + dest='crosperf_root', + action='store', default='/home/mrdmnd/depot2/crosperf', help='Crosperf root directory.') - parser.add_option('--chromeos_root', dest='chromeos_root', action='store', + parser.add_option('--chromeos_root', + dest='chromeos_root', + action='store', default='/home/mrdmnd/chromiumos', help='ChromiumOS root directory.') - parser.add_option('--remote', dest='remote', action='store', + parser.add_option('--remote', + dest='remote', + action='store', help='Host to run test on. Required.') - parser.add_option('--board', dest='board', action='store', + parser.add_option('--board', + dest='board', + action='store', help='Board architecture to run on. Required.') - parser.add_option('--event', dest='event', action='store', + parser.add_option('--event', + dest='event', + action='store', help='Event to profile. Required.') - parser.add_option('-F', dest='sampling_frequencies', action='append', + parser.add_option('-F', + dest='sampling_frequencies', + action='append', help='A target frequency to sample at.') - parser.add_option('-c', dest='sampling_periods', action='append', + parser.add_option('-c', + dest='sampling_periods', + action='append', help='A target period to sample at. Event specific.') - parser.add_option('--benchmark-iterations', dest='benchmark_iterations', - action='store', default=4, help='Number of benchmark iters') - parser.add_option('--test-iterations', dest='test_iterations', - action='store', default=10, help='Number of test iters') - parser.add_option('-p', dest='print_only', action='store_true', + parser.add_option('--benchmark-iterations', + dest='benchmark_iterations', + action='store', + default=4, + help='Number of benchmark iters') + parser.add_option('--test-iterations', + dest='test_iterations', + action='store', + default=10, + help='Number of test iters') + parser.add_option('-p', + dest='print_only', + action='store_true', help='If enabled, will print experiment file and exit.') - parser.add_option('--perf_options', dest='perf_options', action='store', + parser.add_option('--perf_options', + dest='perf_options', + action='store', help='Arbitrary flags to perf. Surround with dblquotes.') options = parser.parse_args()[0] if options.remote is None: @@ -85,16 +108,14 @@ def main(): for freq in options.sampling_frequencies: test_string = str(freq) + 'Freq' experiment_file += EXPERIMENT % (test_string, bench_iters, test_iters, - '-F %s' % freq, - '' if perf_opts is None else perf_opts, - event) + '-F %s' % freq, '' if perf_opts is None + else perf_opts, event) if options.sampling_periods: for period in options.sampling_periods: test_string = str(period) + 'Period' - experiment_file += EXPERIMENT % (test_string, bench_iters, test_iters, - '-c %s' % period, - '' if perf_opts is None else perf_opts, - event) + experiment_file += EXPERIMENT % ( + test_string, bench_iters, test_iters, '-c %s' % period, '' if + perf_opts is None else perf_opts, event) # Point to the target image. experiment_file += DEFAULT_IMAGE % (chromeos_root, board) if options.print_only: @@ -102,7 +123,7 @@ def main(): else: current_time = int(round(time.time() * 1000)) file_name = 'perf_overhead_%s' % str(current_time) - with open(file_name, "w") as f: + with open(file_name, 'w') as f: f.write(experiment_file) try: process = subprocess.Popen(['%s/crosperf' % crosperf_root, file_name]) @@ -112,5 +133,6 @@ def main(): return 1 return 0 + if __name__ == '__main__': exit(main()) |