Created
May 9, 2014 00:39
-
-
Save matthew-brett/9cb5274f7451a3eb8fc0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """ Detect Windows non-SSE2 machines in Firefox crash reports | |
| Uses algorithm described in: | |
| https://groups.google.com/d/msg/mozilla.dev.platform/GWb7C76nRqk/haR0oZkfkWgJ | |
| and replicates results in: | |
| https://groups.google.com/d/msg/mozilla.dev.platform/GWb7C76nRqk/w_T3nzDlVVkJ | |
| Runs on *pub-crashdata.csv.gz files from: | |
| https://crash-analysis.mozilla.com/crash_analysis | |
| """ | |
| from __future__ import division, print_function | |
| import sys | |
| import re | |
| import gzip | |
| import csv | |
| ANA_CPU = re.compile( | |
| r'x86 \| (\w+) family (\d+) model (\d+) stepping (\d+) \| ') | |
| FIELDS = ('vendor', 'family', 'model', 'stepping') | |
| example = 'x86 | GenuineIntel family 6 model 23 stepping 10 | 2' | |
| def read_file(fname): | |
| with gzip.open(fname, 'rt') as fobj: | |
| reader = csv.DictReader(fobj, dialect=csv.excel_tab) | |
| rows = list(reader) | |
| return rows | |
| def get_cpu_info(rows): | |
| return [row['cpu_info'] for row in rows] | |
| def ana_cpu_info(rows): | |
| a_infos = [] | |
| for info in get_cpu_info(rows): | |
| match = ANA_CPU.match(info) | |
| if match is None: | |
| continue | |
| vendor, family, model, stepping = match.groups() | |
| a_infos.append(dict( | |
| zip(FIELDS, | |
| (vendor, int(family), int(model), int(stepping))))) | |
| return a_infos | |
| def do_counts(a_infos, | |
| vendors = ('CentaurHauls', 'GenuineIntel', 'AuthenticAMD')): | |
| total = 0 | |
| sse2 = 0 | |
| for info in a_infos: | |
| vendor, family, model, stepping = ( | |
| info['vendor'], info['family'], info['model'], info['stepping']) | |
| if not vendor in vendors: | |
| continue | |
| total += 1 | |
| if ((vendor == 'AuthenticAMD' and family >= 15) or | |
| (vendor == 'GenuineIntel' and | |
| (family >= 15 or (family == 6 and (model == 9 or model > 11)))) or | |
| (vendor == 'CentaurHauls' and family >= 6 and model >= 10)): | |
| sse2 += 1 | |
| return (total - sse2) / total * 100, total, sse2 | |
| def main(): | |
| for fname in sys.argv[1:]: | |
| rows = read_file(fname) | |
| a_infos = ana_cpu_info(rows) | |
| pct, total, sse2 = do_counts(a_infos) | |
| print('{0}: {1:.2f}'.format(fname, pct)) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment