コード例 #1
0
def main(arguments):
    options, arguments = parse_arguments(arguments)

    output = get_output(arguments[0], options)
    callgraph = get_callgraph(arguments)

    #- Merge ------------------------------------------------------------------
    if not options.preserve_wrappers:
        callgraph_operations.merge_casting_wrappers(callgraph)

    if options.merge_divpolys:
        callgraph_operations.merge_by_division_polynomials(callgraph)

    if options.merge_fields:
        callgraph_operations.merge_by_fields(callgraph)

    #- Output -----------------------------------------------------------------
    try:
        with closing(output):
            callgrind_profile = CallgrindProfile(callgraph)
            callgrind_profile.dump(output)

            sys.exit(0)

    except IOError as error:
        message = "ERROR: Could not store the output.\nReason: {0}"
        print(message.format(error), file=sys.stderr)
        sys.exit(1)
コード例 #2
0
def main(arguments):
    options, arguments = parse_arguments( arguments )
    
    output = get_output( arguments[0], options )
    callgraph = get_callgraph( arguments )
    
    #- Merge ------------------------------------------------------------------ 
    if not options.preserve_wrappers:
        callgraph_operations.merge_casting_wrappers( callgraph )
    
    if options.merge_divpolys:
        callgraph_operations.merge_by_division_polynomials( callgraph )
    
    if options.merge_fields:
        callgraph_operations.merge_by_fields( callgraph )
    
    #- Output -----------------------------------------------------------------
    try:    
        with closing( output ):
            callgrind_profile = CallgrindProfile( callgraph )
            callgrind_profile.dump( output )

            sys.exit(0)
    
    except IOError as error:
        message = "ERROR: Could not store the output.\nReason: {0}"
        print( message.format( error ), file=sys.stderr )
        sys.exit(1)
コード例 #3
0
def main(arguments):
    options, arguments = parse_arguments( arguments )
    
    output = get_output( arguments[0], options )
    callgraph = get_callgraph( arguments )
    
    #- Merge ------------------------------------------------------------------ 
    if not options.preserve_wrappers:
        callgraph_operations.merge_casting_wrappers( callgraph )
    
    if options.merge_divpolys:
        callgraph_operations.merge_by_division_polynomials( callgraph )
    
    if options.merge_fields:
        callgraph_operations.merge_by_fields( callgraph )
    
    #- Prune ------------------------------------------------------------------
    if options.threshold:
        callgraph_operations.apply_threshold( callgraph, options.threshold / 100 )
    
    #- Print ------------------------------------------------------------------
    try:
        with closing( output ):
            header = "%% Table of the {limit} most expensive functions " \
                     "(first sort key: cumulative time; second key: inline time)\n" \
                     "%% Cost threshold: {threshold}%\n" \
                     "%% Merged: {merged}\n" \
                     "%% Generated on {date} from:\n" \
                     "%% {input}"
            merge_options = [
                           (options.preserve_wrappers, "preserved casting wrappers"),
                           (options.merge_divpolys, "division polynomials namespaces"),
                           (options.merge_fields, "fields namespaces" )
                       ]
            header = header.format(
                               limit = options.limit,
                               threshold = int( options.threshold ),
                               merged = ", ".join( [ m[1] for m in merge_options if m[0] ] ),
                               date = datetime.now().strftime("%Y/%m/%d %H:%M:%S"),
                               input = "\n%% ".join( arguments ), 
                           )
            print( header, file=output )
            
            functions = sorted( callgraph, key=function_sort_key, reverse=True )
            rows = [ prepare_row( f, callgraph.total_time() )
                       for f in functions[ : options.limit ] ]
            
            # Sort again to prevent (seemingly) wrong order
            # from rounding to the same value
            for row in sorted( rows, reverse=True ):
                print( format_row( row ), file=output )

        sys.exit(0)
    
    except IOError as error:
        message = "ERROR: Could not store the output.\nReason: {0}"
        print( message.format( error), file=sys.stderr )
        sys.exit(1)
コード例 #4
0
def main(arguments):
    options, arguments = parse_arguments(arguments)

    output = get_output(arguments[0], options)
    callgraph = get_callgraph(arguments)

    #- Merge ------------------------------------------------------------------
    if not options.preserve_wrappers:
        callgraph_operations.merge_casting_wrappers(callgraph)

    if options.merge_divpolys:
        callgraph_operations.merge_by_division_polynomials(callgraph)

    if options.merge_fields:
        callgraph_operations.merge_by_fields(callgraph)

    #- Prune ------------------------------------------------------------------
    if options.threshold:
        callgraph_operations.apply_threshold(
            callgraph, options.threshold / 100)

    #- Print ------------------------------------------------------------------
    try:
        with closing(output):
            header = "// Call Graph with\n" \
                     "// Cost threshold: {threshold}%\n" \
                     "// Merged: {merged}\n" \
                     "// Generated on {date} from:\n" \
                     "// {input}"
            merge_options = [
                (options.preserve_wrappers, "preserved casting wrappers"),
                (options.merge_divpolys,
                 "division polynomials namespaces"),
                (options.merge_fields, "fields namespaces")
            ]
            header = header.format(
                threshold=int(options.threshold),
                merged=", ".join([m[1] for m in merge_options if m[0]]),
                date=datetime.now().strftime("%Y/%m/%d %H:%M:%S"),
                input="\n// ".join(arguments),
            )
            print(header, file=output)

            dot_callgraph = DotCallgraph(callgraph)
            dot_callgraph.dump(output)

            sys.exit(0)

    except IOError as error:
        message = "ERROR: Could not store the output.\nReason: {0}"
        print(message.format(error), file=sys.stderr)
        sys.exit(1)
コード例 #5
0
def main(arguments):
    options, arguments = parse_arguments( arguments )
    
    output = get_output( arguments[0], options )
    callgraph = get_callgraph( arguments )
    
    #- Merge ------------------------------------------------------------------ 
    if not options.preserve_wrappers:
        callgraph_operations.merge_casting_wrappers( callgraph )
    
    if options.merge_divpolys:
        callgraph_operations.merge_by_division_polynomials( callgraph )
    
    if options.merge_fields:
        callgraph_operations.merge_by_fields( callgraph )
    
    #- Prune ------------------------------------------------------------------
    if options.threshold:
        callgraph_operations.apply_threshold( callgraph, options.threshold / 100 )
    
    #- Print ------------------------------------------------------------------
    try:
        with closing( output ):
            header = "// Call Graph with\n" \
                     "// Cost threshold: {threshold}%\n" \
                     "// Merged: {merged}\n" \
                     "// Generated on {date} from:\n" \
                     "// {input}"
            merge_options = [
                           (options.preserve_wrappers, "preserved casting wrappers"),
                           (options.merge_divpolys, "division polynomials namespaces"),
                           (options.merge_fields, "fields namespaces" )
                       ]
            header = header.format(
                               threshold = int( options.threshold ),
                               merged = ", ".join( [ m[1] for m in merge_options if m[0] ] ),
                               date = datetime.now().strftime("%Y/%m/%d %H:%M:%S"),
                               input = "\n// ".join( arguments ), 
                           )
            print( header, file=output )

            dot_callgraph = DotCallgraph( callgraph  )
            dot_callgraph.dump( output )

            sys.exit(0)
    
    except IOError as error:
        message = "ERROR: Could not store the output.\nReason: {0}"
        print( message.format( error), file=sys.stderr )
        sys.exit(1)