diff options
author | cmp@chromium.org <cmp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-26 01:37:15 +0000 |
---|---|---|
committer | cmp@chromium.org <cmp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-26 01:37:15 +0000 |
commit | 8d445e984977ab24b720435938538b7dd0e3c0b7 (patch) | |
tree | 62cd6799936d659b89b011db9aed0edcfcd5fbcd /tools/perf_expectations/make_expectations.py | |
parent | b4a49abd28fba882a65a81a75012a7e2d980216b (diff) | |
download | chromium_src-8d445e984977ab24b720435938538b7dd0e3c0b7.zip chromium_src-8d445e984977ab24b720435938538b7dd0e3c0b7.tar.gz chromium_src-8d445e984977ab24b720435938538b7dd0e3c0b7.tar.bz2 |
Reuse ASCII conversion in comparing hashes.
TEST=make_expectations.py continues to run in <1s in
the no changes case
Review URL: http://codereview.chromium.org/6905020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82968 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/perf_expectations/make_expectations.py')
-rwxr-xr-x | tools/perf_expectations/make_expectations.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tools/perf_expectations/make_expectations.py b/tools/perf_expectations/make_expectations.py index 3bb83d7..fc7f46f 100755 --- a/tools/perf_expectations/make_expectations.py +++ b/tools/perf_expectations/make_expectations.py @@ -88,6 +88,14 @@ def GetRowData(data, key): return rowdata +def GetRowDigest(rowdata, key): + sha1 = hashlib.sha1() + rowdata = [str(possibly_unicode_string).encode('ascii') + for possibly_unicode_string in rowdata] + sha1.update(str(rowdata) + key) + return sha1.hexdigest()[0:8] + + def WriteJson(filename, data, keys): """Write a list of |keys| in |data| to the file specified in |filename|.""" try: @@ -99,14 +107,8 @@ def WriteJson(filename, data, keys): jsondata = [] for key in keys: rowdata = GetRowData(data, key) - # Include an updated checksum. - sha1 = hashlib.sha1() - rowdata = [str(possibly_unicode_string).encode('ascii') - for possibly_unicode_string in rowdata] - sha1.update(str(rowdata) + key) - rowdata.append('"sha1": "%s"' % sha1.hexdigest()[0:8]) - + rowdata.append('"sha1": "%s"' % GetRowDigest(rowdata, key)) jsondata.append('"%s": {%s}' % (key, ', '.join(rowdata))) jsondata.append('"load": true') jsontext = '{%s\n}' % ',\n '.join(jsondata) @@ -154,9 +156,9 @@ def Main(args): original_checksum = value.get('sha1', '') if 'sha1' in value: del value['sha1'] - sha1 = hashlib.sha1() - sha1.update(str(GetRowData(perf, key)) + key) - if original_checksum == sha1.hexdigest()[0:8]: + rowdata = GetRowData(perf, key) + computed_checksum = GetRowDigest(rowdata, key) + if original_checksum == computed_checksum: OutputMessage('checksum matches, skipping') continue |