예제 #1
0
def main():
    parser = argparse.ArgumentParser(description='A programs that generate a'
                            ' P4 program for benchmarking a particular feature')
    parser.add_argument('--feature', choices=features,
                help='select a feature for benchmarking')
    parser.add_argument('--checksum', default=False, action='store_true',
                            help='perform update checksum')
    # Processing options
    parser.add_argument('--tables', default=1, type=int, help='number of tables')
    parser.add_argument('--table-size', default=1, type=int,
                            help='number of rules in the table')
    # Parser (Field|Header) and Packet Modification options
    parser.add_argument('--headers', default=1, type=int, help='number of headers')
    parser.add_argument('--fields', default=1, type=int, help='number of fields')
    # Parser Complexity
    parser.add_argument('--depth', default=1, type=int,
                            help='the depth of the parse graph')
    parser.add_argument('--fanout', default=2, type=int,
                            help='the number of branch of a node in the parse graph')
    # State Access option
    parser.add_argument('--registers', default=1, type=int, help='number of registers')
    parser.add_argument('--nb-element', default=1024, type=int,
                            help='number of element in a register')
    parser.add_argument('--element-width', default=32, type=int,
                            help='the bit width of a register element')
    # Parser Action complexity
    parser.add_argument('--operations', default=1, type=int,
                            help='the number of set-field/read/write operations')

    args = parser.parse_args()

    if args.feature == 'parse-header':
        benchmark_parser_header(args.headers, args.fields, do_checksum=args.checksum)
    elif args.feature == 'parse-field':
        benchmark_parser_with_header_field(args.fields, do_checksum=args.checksum)
    elif args.feature == 'parse-complex':
        parser_complexity(args.depth, args.fanout)
    elif args.feature == 'set-field':
        benchmark_field_write(args.operations, do_checksum=args.checksum)
    elif args.feature == 'add-header':
        benchmark_modification(args.headers, args.fields, 'add')
    elif args.feature == 'rm-header':
        benchmark_modification(args.headers, args.fields, 'rm')
    elif args.feature == 'pipeline':
        benchmark_pipeline(args.tables, args.table_size)
    elif args.feature == 'read-state':
        benchmark_memory(args.registers, args.element_width, args.nb_element,
                            args.operations, False)
    elif args.feature == 'write-state':
        benchmark_memory(args.registers, args.element_width, args.nb_element,
                            args.operations, True)
    else:
        parser.print_help()
        sys.exit(0)

    print "Generate files to 'output' directory"
def main():
    parser = argparse.ArgumentParser(
        description='A programs that generate a'
        ' P4 program for benchmarking a particular feature')
    parser.add_argument('--feature',
                        choices=features,
                        help='select a feature for benchmarking')
    parser.add_argument('--checksum',
                        default=False,
                        action='store_true',
                        help='perform update checksum')
    # Parser (Field|Header) and Packet Modification options
    parser.add_argument('--headers',
                        default=1,
                        type=int,
                        help='number of headers')
    parser.add_argument('--fields',
                        default=1,
                        type=int,
                        help='number of fields')
    # Parser Complexity
    parser.add_argument('--depth',
                        default=1,
                        type=int,
                        help='the depth of the parse graph')
    parser.add_argument(
        '--fanout',
        default=2,
        type=int,
        help='the number of branch of a node in the parse graph')

    args = parser.parse_args()

    if args.feature == 'parse-header':
        benchmark_parser_header(args.headers,
                                args.fields,
                                do_checksum=args.checksum)
    elif args.feature == 'parse-field':
        benchmark_parser_with_header_field(args.fields,
                                           do_checksum=args.checksum)
    elif args.feature == 'parse-complex':
        parser_complexity(args.depth, args.fanout)
    elif args.feature == 'parse-header16':
        benchmark_parser_header(args.headers,
                                args.fields,
                                do_checksum=args.checksum)
    elif args.feature == 'parse-field16':
        print("cazz")
    #benchmark_parser_with_header_field(args.fields, do_checksum=args.checksum)
    elif args.feature == 'parse-complex16':
        print("cazzz")
예제 #3
0
 def test_benchmark_complex_branching_generator2(self):
     ret = parser_complexity(4, 5)
     self.assertTrue(ret)
     prog = 'main'
     ret = call([
         self.p4c,
         'output/%s.p4' % prog, '--json',
         'output/%s.json' % prog
     ])
     self.assertEqual(ret, 0)
예제 #4
0
 def test_benchmark_parser_complexity_big(self):
     ret = parser_complexity(5, 5)
     self.assertTrue(ret)
예제 #5
0
 def test_benchmark_parser_complexity_big_depth(self):
     ret = parser_complexity(500, 1)
     self.assertTrue(ret)
예제 #6
0
 def test_benchmark_parser_complexity_medium_depth(self):
     ret = parser_complexity(10, 2)
     self.assertTrue(ret)
예제 #7
0
 def test_benchmark_parser_complexity_big_fanout(self):
     ret = parser_complexity(2, 10)
     self.assertTrue(ret)
예제 #8
0
 def test_benchmark_parser_complexity_small(self):
     ret = parser_complexity(2, 2)
     self.assertTrue(ret)