layout/generic/frame-graph.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/generic/frame-graph.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,41 @@
     1.4 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.7 +
     1.8 +"""
     1.9 +Take the *.framedata files from graph-frameclasses.js and combine them
    1.10 +into a single graphviz file.
    1.11 +
    1.12 +stdin: a list of .framedata file names (e.g. from xargs)
    1.13 +stdout: a graphviz file
    1.14 +
    1.15 +e.g. `find <objdir> -name "*.framedata" | python aggregate-frameclasses.py |
    1.16 +  dot -Tpng -o frameclasses-graph.png -`
    1.17 +"""
    1.18 +
    1.19 +import sys
    1.20 +
    1.21 +classdict = {}
    1.22 +
    1.23 +for line in sys.stdin:
    1.24 +    file = line.strip()
    1.25 +    fd = open(file)
    1.26 +
    1.27 +    output = None
    1.28 +    for line in fd:
    1.29 +        if line.startswith('CLASS-DEF: '):
    1.30 +            cname = line[11:-1]
    1.31 +            if cname not in classdict:
    1.32 +                output = classdict[cname] = []
    1.33 +            else:
    1.34 +                output = None
    1.35 +        elif output is not None:
    1.36 +            output.append(line)
    1.37 +
    1.38 +sys.stdout.write('digraph g {\n')
    1.39 +
    1.40 +for olist in classdict.itervalues():
    1.41 +    for line in olist:
    1.42 +        sys.stdout.write(line)
    1.43 +
    1.44 +sys.stdout.write('}\n')

mercurial