Esempio n. 1
0
def show_profile(args, sample_producer):
    resolver = symbol_resolver(args)
    time_range = get_time_range(args)

    node_filters = []

    if args.min_duration:
        min_duration = prof.parse_time_as_nanos(args.min_duration)
        node_filters.append(lambda node, tree_root: node.resident_time >= min_duration)

    if args.min_hits:
        if args.min_hits.endswith('%'):
            node_filters.append(MinHitPercentageFilter(parse_percentage(args.min_hits)))
        else:
            node_filters.append(MinHitCountFilter(int(args.min_hits)))

    def node_filter(*args):
        for filter in node_filters:
            if not filter(*args):
                return False
        return True

    with get_trace_reader(args) as reader:
        prof.print_profile(sample_producer(reader.get_traces()),
            symbol_resolver=resolver,
            caller_oriented=args.caller_oriented,
            grouping=groupers[args.group_by](),
            src_addr_formatter=src_addr_formatter(args),
            root_function=args.function,
            node_filter=node_filter,
            time_range=time_range,
            max_levels=args.max_levels)
Esempio n. 2
0
def get_time_range(args):
    start = prof.parse_time_as_nanos(args.since) if args.since else None
    end = prof.parse_time_as_nanos(args.until) if args.until else None

    if args.period:
        if start and end:
            raise InvalidArgumentsException("--period cannot be used when both --since and --until are specified")

        period = prof.parse_time_as_nanos(args.period)
        if start:
            end = start + period
        elif end:
            start = end - period
        else:
            raise InvalidArgumentsException("--period must be used with --since or --until specified")

    return trace.TimeRange(start, end)
Esempio n. 3
0
def get_time_range(args):
    start = prof.parse_time_as_nanos(args.since) if args.since else None
    end = prof.parse_time_as_nanos(args.until) if args.until else None

    if args.period:
        if start and end:
            raise InvalidArgumentsException(
                "--period cannot be used when both --since and --until are specified"
            )

        period = prof.parse_time_as_nanos(args.period)
        if start:
            end = start + period
        elif end:
            start = end - period
        else:
            raise InvalidArgumentsException(
                "--period must be used with --since or --until specified")

    return trace.TimeRange(start, end)
Esempio n. 4
0
def show_profile(args, sample_producer):
    resolver = symbol_resolver(args)
    time_range = get_time_range(args)

    if args.min_duration:
        min_duration = prof.parse_time_as_nanos(args.min_duration)
        node_filter = lambda node: node.resident_time >= min_duration
    else:
        node_filter = None

    with get_trace_reader(args) as reader:
        prof.print_profile(sample_producer(reader.get_traces()),
            symbol_resolver=resolver,
            caller_oriented=args.caller_oriented,
            merge_threads=args.merge_threads,
            src_addr_formatter=src_addr_formatter(args),
            root_function=args.function,
            node_filter=node_filter,
            time_range=time_range,
            max_levels=args.max_levels)
Esempio n. 5
0
def show_profile(args, sample_producer):
    resolver = symbol_resolver(args)
    time_range = get_time_range(args)

    if args.min_duration:
        min_duration = prof.parse_time_as_nanos(args.min_duration)
        node_filter = lambda node: node.resident_time >= min_duration
    else:
        node_filter = None

    with get_trace_reader(args) as reader:
        prof.print_profile(sample_producer(reader.get_traces()),
                           symbol_resolver=resolver,
                           caller_oriented=args.caller_oriented,
                           merge_threads=args.merge_threads,
                           src_addr_formatter=src_addr_formatter(args),
                           root_function=args.function,
                           node_filter=node_filter,
                           time_range=time_range,
                           max_levels=args.max_levels)