예제 #1
0
def main():
    parser = ArgumentParser(description="Process GCTracer's NVP output")
    parser.add_argument('keys',
                        metavar='KEY',
                        type=str,
                        nargs='+',
                        help='the keys of NVPs to process')
    parser.add_argument('--histogram-type',
                        metavar='<linear|log2>',
                        type=str,
                        nargs='?',
                        default="linear",
                        help='histogram type to use (default: linear)')
    linear_group = parser.add_argument_group('linear histogram specific')
    linear_group.add_argument('--linear-histogram-granularity',
                              metavar='GRANULARITY',
                              type=int,
                              nargs='?',
                              default=5,
                              help='histogram granularity (default: 5)')
    log2_group = parser.add_argument_group('log2 histogram specific')
    log2_group.add_argument('--log2-histogram-init-bucket',
                            metavar='START',
                            type=int,
                            nargs='?',
                            default=64,
                            help='initial buck size (default: 64)')
    parser.add_argument('--histogram-omit-empty-buckets',
                        dest='histogram_omit_empty',
                        action='store_true',
                        help='omit empty histogram buckets')
    parser.add_argument('--no-histogram',
                        dest='histogram',
                        action='store_false',
                        help='do not print histogram')
    parser.set_defaults(histogram=True)
    parser.set_defaults(histogram_omit_empty=False)
    args = parser.parse_args()

    histogram = None
    if args.histogram:
        bucket_trait = None
        if args.histogram_type == "log2":
            bucket_trait = Log2Bucket(args.log2_histogram_init_bucket)
        else:
            bucket_trait = LinearBucket(args.linear_histogram_granularity)
        histogram = Histogram(bucket_trait, not args.histogram_omit_empty)

    categories = [Category(key, deepcopy(histogram)) for key in args.keys]

    while True:
        line = stdin.readline()
        if not line:
            break
        obj = split_nvp(line)
        for category in categories:
            category.process_entry(obj)

    for category in categories:
        print(category)
예제 #2
0
def main():
  parser = ArgumentParser(description="Process GCTracer's NVP output")
  parser.add_argument('keys', metavar='KEY', type=str, nargs='+',
                      help='the keys of NVPs to process')
  parser.add_argument('--histogram-type', metavar='<linear|log2>',
                      type=str, nargs='?', default="linear",
                      help='histogram type to use (default: linear)')
  linear_group = parser.add_argument_group('linear histogram specific')
  linear_group.add_argument('--linear-histogram-granularity',
                            metavar='GRANULARITY', type=int, nargs='?',
                            default=5,
                            help='histogram granularity (default: 5)')
  log2_group = parser.add_argument_group('log2 histogram specific')
  log2_group.add_argument('--log2-histogram-init-bucket', metavar='START',
                          type=int, nargs='?', default=64,
                          help='initial buck size (default: 64)')
  parser.add_argument('--histogram-omit-empty-buckets',
                      dest='histogram_omit_empty',
                      action='store_true',
                      help='omit empty histogram buckets')
  parser.add_argument('--no-histogram', dest='histogram',
                      action='store_false', help='do not print histogram')
  parser.set_defaults(histogram=True)
  parser.set_defaults(histogram_omit_empty=False)
  parser.add_argument('--rank', metavar='<no|min|max|avg>',
                      type=str, nargs='?',
                      default="no",
                      help="rank keys by metric (default: no)")
  parser.add_argument('--csv', dest='csv',
                      action='store_true', help='provide output as csv')
  args = parser.parse_args()

  histogram = None
  if args.histogram:
    bucket_trait = None
    if args.histogram_type == "log2":
      bucket_trait = Log2Bucket(args.log2_histogram_init_bucket)
    else:
      bucket_trait = LinearBucket(args.linear_histogram_granularity)
    histogram = Histogram(bucket_trait, not args.histogram_omit_empty)

  categories = [ Category(key, deepcopy(histogram), args.csv)
                 for key in args.keys ]

  while True:
    line = stdin.readline()
    if not line:
      break
    obj = split_nvp(line)
    for category in categories:
      category.process_entry(obj)

  # Filter out empty categories.
  categories = [x for x in categories if not x.empty()]

  if args.rank != "no":
    categories = sorted(categories, key=make_key_func(args.rank), reverse=True)

  for category in categories:
    print(category)
예제 #3
0
def main():
  parser = ArgumentParser(description="Process GCTracer's NVP output")
  parser.add_argument('keys', metavar='KEY', type=str, nargs='+',
                      help='the keys (names) to process')
  parser.add_argument('--histogram-granularity', metavar='GRANULARITY',
                      type=int, nargs='?', default=5,
                      help='histogram granularity (default: 5)')
  parser.add_argument('--no-histogram-print-empty', dest='histogram_print_empty',
                      action='store_false',
                      help='print empty histogram buckets')
  feature_parser = parser.add_mutually_exclusive_group(required=False)
  feature_parser.add_argument('--histogram', dest='histogram',
                              action='store_true',
                              help='print histogram')
  feature_parser.add_argument('--no-histogram', dest='histogram',
                              action='store_false',
                              help='do not print histogram')
  parser.set_defaults(histogram=True)
  parser.set_defaults(histogram_print_empty=True)
  args = parser.parse_args()

  histogram = None
  if args.histogram:
    histogram = Histogram(args.histogram_granularity, args.histogram_print_empty)

  categories = [ Category(key, deepcopy(histogram))
                 for key in args.keys ]

  while True:
    line = stdin.readline()
    if not line:
      break
    obj = split_nvp(line)
    for category in categories:
      category.process_entry(obj)

  for category in categories:
    print(category)
예제 #4
0
def main():
    parser = ArgumentParser(description="Process GCTracer's NVP output")
    parser.add_argument('keys',
                        metavar='KEY',
                        type=str,
                        nargs='+',
                        help='the keys of NVPs to process')
    parser.add_argument('--histogram-type',
                        metavar='<linear|log2>',
                        type=str,
                        nargs='?',
                        default="linear",
                        help='histogram type to use (default: linear)')
    linear_group = parser.add_argument_group('linear histogram specific')
    linear_group.add_argument('--linear-histogram-granularity',
                              metavar='GRANULARITY',
                              type=int,
                              nargs='?',
                              default=5,
                              help='histogram granularity (default: 5)')
    log2_group = parser.add_argument_group('log2 histogram specific')
    log2_group.add_argument('--log2-histogram-init-bucket',
                            metavar='START',
                            type=int,
                            nargs='?',
                            default=64,
                            help='initial buck size (default: 64)')
    parser.add_argument('--histogram-omit-empty-buckets',
                        dest='histogram_omit_empty',
                        action='store_true',
                        help='omit empty histogram buckets')
    parser.add_argument('--no-histogram',
                        dest='histogram',
                        action='store_false',
                        help='do not print histogram')
    parser.set_defaults(histogram=True)
    parser.set_defaults(histogram_omit_empty=False)
    parser.add_argument('--rank',
                        metavar='<no|min|max|avg>',
                        type=str,
                        nargs='?',
                        default="no",
                        help="rank keys by metric (default: no)")
    parser.add_argument('--csv',
                        dest='csv',
                        action='store_true',
                        help='provide output as csv')
    parser.add_argument('--percentiles',
                        dest='percentiles',
                        type=str,
                        default="",
                        help='comma separated list of percentiles')
    args = parser.parse_args()

    histogram = None
    if args.histogram:
        bucket_trait = None
        if args.histogram_type == "log2":
            bucket_trait = Log2Bucket(args.log2_histogram_init_bucket)
        else:
            bucket_trait = LinearBucket(args.linear_histogram_granularity)
        histogram = Histogram(bucket_trait, not args.histogram_omit_empty)

    percentiles = []
    for percentile in args.percentiles.split(','):
        try:
            percentiles.append(float(percentile))
        except ValueError:
            pass

    categories = [
        Category(key, deepcopy(histogram), args.csv, percentiles)
        for key in args.keys
    ]

    while True:
        line = stdin.readline()
        if not line:
            break
        obj = split_nvp(line)
        for category in categories:
            category.process_entry(obj)

    # Filter out empty categories.
    categories = [x for x in categories if not x.empty()]

    if args.rank != "no":
        categories = sorted(categories,
                            key=make_key_func(args.rank),
                            reverse=True)

    for category in categories:
        print(category)