예제 #1
0
파일: trace.py 프로젝트: vyommani/osv
def print_summary(args, printer=sys.stdout.write):
    timed_producer = timed_trace_producer()
    timed_samples = []

    count_per_tp = defaultdict(lambda: 0)
    count = 0
    min_time = None
    max_time = None

    with get_trace_reader(args) as reader:
        for t in reader.get_traces():
            count += 1
            count_per_tp[t.tp] += 1

            if not min_time:
                min_time = t.time
            else:
                min_time = min(min_time, t.time)

            max_time = max(max_time, t.time)

            if args.timed:
                timed = timed_producer(t)
                if timed:
                    timed_samples.append(timed)

    if count == 0:
        print "No samples"
        return

    print "Collected %d samples spanning %s" % (count, prof.format_time(max_time - min_time))

    max_name_len = reduce(max, map(lambda tp: len(tp.name), count_per_tp.iterkeys()))
    format = "  %%-%ds %%8s" % (max_name_len)
    print "\nTracepoint statistics:\n"
    print format % ("name", "count")
    print format % ("----", "-----")

    for tp, count in sorted(count_per_tp.iteritems(), key=lambda (tp, count): tp.name):
        print format % (tp.name, count)

    if args.timed:
        format = "  %-20s %8s %8s %8s %8s %8s %8s %8s %15s"
        print "\nTimed tracepoints [ms]:\n"

        if not timed_samples:
            print "  None"
        else:
            print format % ("name", "count", "min", "50%", "90%", "99%", "99.9%", "max", "total")
            print format % ("----", "-----", "---", "---", "---", "---", "-----", "---", "-----")

            for name, traces in get_timed_traces_per_function(timed_samples).iteritems():
                    samples = sorted(map(attrgetter('duration'), traces))
                    print format % (
                        name,
                        len(samples),
                        format_duration(get_percentile(samples, 0)),
                        format_duration(get_percentile(samples, 0.5)),
                        format_duration(get_percentile(samples, 0.9)),
                        format_duration(get_percentile(samples, 0.99)),
                        format_duration(get_percentile(samples, 0.999)),
                        format_duration(get_percentile(samples, 1)),
                        format_duration(sum(samples)))

    print
예제 #2
0
파일: trace.py 프로젝트: tinti/osv
def print_summary(args, printer=sys.stdout.write):
    time_range = get_time_range(args)
    timed_producer = prof.timed_trace_producer()
    timed_samples = []

    count_per_tp = defaultdict(lambda: 0)
    count = 0
    min_time = None
    max_time = None

    with get_trace_reader(args) as reader:
        for t in reader.get_traces():
            if t.time in time_range:
                count += 1
                count_per_tp[t.tp] += 1

                if not min_time:
                    min_time = t.time
                else:
                    min_time = min(min_time, t.time)

                max_time = max(max_time, t.time)

            if args.timed:
                timed = timed_producer(t)
                if timed:
                    timed_samples.append(timed)

    if args.timed:
        timed_samples.extend((timed_producer.finish()))

    if count == 0:
        print "No samples"
        return

    print "Collected %d samples spanning %s" % (count, prof.format_time(max_time - min_time))

    max_name_len = reduce(max, map(lambda tp: len(tp.name), count_per_tp.iterkeys()))
    format = "  %%-%ds %%8s" % (max_name_len)
    print "\nTracepoint statistics:\n"
    print format % ("name", "count")
    print format % ("----", "-----")

    for tp, count in sorted(count_per_tp.iteritems(), key=lambda (tp, count): tp.name):
        print format % (tp.name, count)

    if args.timed:
        format = "  %-20s %8s %8s %8s %8s %8s %8s %8s %15s"
        print "\nTimed tracepoints [ms]:\n"

        timed_samples = filter(lambda t: t.time_range.intersection(time_range), timed_samples)

        if not timed_samples:
            print "  None"
        else:
            print format % ("name", "count", "min", "50%", "90%", "99%", "99.9%", "max", "total")
            print format % ("----", "-----", "---", "---", "---", "---", "-----", "---", "-----")

            for name, traces in get_timed_traces_per_function(timed_samples).iteritems():
                    samples = sorted(list((t.time_range.intersection(time_range).length() for t in traces)))
                    print format % (
                        name,
                        len(samples),
                        format_duration(get_percentile(samples, 0)),
                        format_duration(get_percentile(samples, 0.5)),
                        format_duration(get_percentile(samples, 0.9)),
                        format_duration(get_percentile(samples, 0.99)),
                        format_duration(get_percentile(samples, 0.999)),
                        format_duration(get_percentile(samples, 1)),
                        format_duration(sum(samples)))

    print
예제 #3
0
def print_summary(args, printer=sys.stdout.write):
    time_range = get_time_range(args)
    timed_producer = prof.timed_trace_producer()
    timed_samples = []

    count_per_tp = defaultdict(lambda: 0)
    count = 0
    min_time = None
    max_time = None

    class CpuTimeRange:
        def __init__(self):
            self.min = None
            self.max = None

        def update(self, time):
            if self.min is None or time < self.min:
                self.min = time
            if self.max is None or time > self.max:
                self.max = time

    cpu_time_ranges = defaultdict(CpuTimeRange)

    with get_trace_reader(args) as reader:
        for t in reader.get_traces():
            if t.time in time_range:
                cpu_time_ranges[t.cpu].update(t.time)
                count += 1
                count_per_tp[t.tp] += 1

                if not min_time:
                    min_time = t.time
                else:
                    min_time = min(min_time, t.time)

                if not max_time:
                    max_time = t.time
                else:
                    max_time = max(max_time, t.time)

            if args.timed:
                timed = timed_producer(t)
                if timed:
                    timed_samples.append(timed)

    if args.timed:
        timed_samples.extend((timed_producer.finish()))

    if count == 0:
        print("No samples")
        return

    print("Collected %d samples spanning %s" %
          (count, prof.format_time(max_time - min_time)))

    print("\nTime ranges:\n")
    for cpu, r in sorted(list(cpu_time_ranges.items()),
                         key=lambda c_r: c_r[1].min):
        print("  CPU 0x%02d: %s - %s = %10s" % (cpu, trace.format_time(
            r.min), trace.format_time(r.max), prof.format_time(r.max - r.min)))

    max_name_len = reduce(max,
                          [len(tp.name) for tp in iter(count_per_tp.keys())])
    format = "  %%-%ds %%8s" % (max_name_len)
    print("\nTracepoint statistics:\n")
    print(format % ("name", "count"))
    print(format % ("----", "-----"))

    for tp, count in sorted(iter(count_per_tp.items()),
                            key=lambda tp_count: tp_count[0].name):
        print(format % (tp.name, count))

    if args.timed:
        format = "  %-20s %8s %8s %8s %8s %8s %8s %8s %15s"
        print("\nTimed tracepoints [ms]:\n")

        timed_samples = [
            t for t in timed_samples if t.time_range.intersection(time_range)
        ]

        if not timed_samples:
            print("  None")
        else:
            print(format % ("name", "count", "min", "50%", "90%", "99%",
                            "99.9%", "max", "total"))
            print(format % ("----", "-----", "---", "---", "---", "---",
                            "-----", "---", "-----"))

            for name, traces in get_timed_traces_per_function(
                    timed_samples).items():
                samples = sorted(
                    list((t.time_range.intersection(time_range).length()
                          for t in traces)))
                print(format %
                      (name, len(samples),
                       format_duration(get_percentile(samples, 0)),
                       format_duration(get_percentile(samples, 0.5)),
                       format_duration(get_percentile(samples, 0.9)),
                       format_duration(get_percentile(samples, 0.99)),
                       format_duration(get_percentile(samples, 0.999)),
                       format_duration(get_percentile(
                           samples, 1)), format_duration(sum(samples))))

    print()
예제 #4
0
파일: trace.py 프로젝트: Akhu18991/osv
def print_summary(args, printer=sys.stdout.write):
    time_range = get_time_range(args)
    timed_producer = prof.timed_trace_producer()
    timed_samples = []

    count_per_tp = defaultdict(lambda: 0)
    count = 0
    min_time = None
    max_time = None

    class CpuTimeRange:
        def __init__(self):
            self.min = None
            self.max = None

        def update(self, time):
            if self.min is None or time < self.min:
                self.min = time
            if self.max is None or time > self.max:
                self.max = time

    cpu_time_ranges = defaultdict(CpuTimeRange)

    with get_trace_reader(args) as reader:
        for t in reader.get_traces():
            if t.time in time_range:
                cpu_time_ranges[t.cpu].update(t.time)
                count += 1
                count_per_tp[t.tp] += 1

                if not min_time:
                    min_time = t.time
                else:
                    min_time = min(min_time, t.time)

                max_time = max(max_time, t.time)

            if args.timed:
                timed = timed_producer(t)
                if timed:
                    timed_samples.append(timed)

    if args.timed:
        timed_samples.extend((timed_producer.finish()))

    if count == 0:
        print "No samples"
        return

    print "Collected %d samples spanning %s" % (count, prof.format_time(max_time - min_time))

    print "\nTime ranges:\n"
    for cpu, r in sorted(cpu_time_ranges.items(), key=lambda (c, r): r.min):
        print "  CPU 0x%02d: %s - %s = %10s" % (cpu,
            trace.format_time(r.min),
            trace.format_time(r.max),
            prof.format_time(r.max - r.min))

    max_name_len = reduce(max, map(lambda tp: len(tp.name), count_per_tp.iterkeys()))
    format = "  %%-%ds %%8s" % (max_name_len)
    print "\nTracepoint statistics:\n"
    print format % ("name", "count")
    print format % ("----", "-----")

    for tp, count in sorted(count_per_tp.iteritems(), key=lambda (tp, count): tp.name):
        print format % (tp.name, count)

    if args.timed:
        format = "  %-20s %8s %8s %8s %8s %8s %8s %8s %15s"
        print "\nTimed tracepoints [ms]:\n"

        timed_samples = filter(lambda t: t.time_range.intersection(time_range), timed_samples)

        if not timed_samples:
            print "  None"
        else:
            print format % ("name", "count", "min", "50%", "90%", "99%", "99.9%", "max", "total")
            print format % ("----", "-----", "---", "---", "---", "---", "-----", "---", "-----")

            for name, traces in get_timed_traces_per_function(timed_samples).iteritems():
                samples = sorted(list((t.time_range.intersection(time_range).length() for t in traces)))
                print format % (
                    name,
                    len(samples),
                    format_duration(get_percentile(samples, 0)),
                    format_duration(get_percentile(samples, 0.5)),
                    format_duration(get_percentile(samples, 0.9)),
                    format_duration(get_percentile(samples, 0.99)),
                    format_duration(get_percentile(samples, 0.999)),
                    format_duration(get_percentile(samples, 1)),
                    format_duration(sum(samples)))

    print