Пример #1
0
        'max_seq_len': [20, 40, 80, 160, 320],
        'num_client': [2, 4, 8, 16, 32],
    }

    fp = open('benchmark.result', 'w')
    for var_name, var_lst in experiments.items():
        # set common args
        args = namedtuple('args', ','.join(common.keys()))
        for k, v in common.items():
            setattr(args, k, v)

        avg_speed = []
        for var in var_lst:
            # override exp args
            setattr(args, var_name, var)
            server = BertServer(args)
            server.start()

            # sleep until server is ready
            time.sleep(15)
            all_clients = [
                BenchmarkClient(args) for _ in range(args.num_client)
            ]

            tprint('num_client: %d' % len(all_clients))
            for bc in all_clients:
                bc.start()

            all_thread_speed = []
            for bc in all_clients:
                bc.join()
Пример #2
0
            'batch_size_per_worker': 128,
            'client_batch_size': 2048,
            'client_seq_len': 100,
            'num_client': [1, 2, 3, 4],
        },
    ]

    # exp1
    exp = experiments[0]
    var_name = 'max_seq_len'
    for var in exp[var_name]:
        args = namedtuple('args',
                          ','.join(list(common.keys()) + list(exp.keys())))
        for k, v in common.items():
            setattr(args, k, v)
        for k, v in exp.items():
            setattr(args, k, v)
        # override the var_name
        setattr(args, var_name, var)

        print('will start a sever with args: %s' % args)
        server = BertServer(args)
        server.start()

        for _ in range(args.num_client):
            bc = BenchmarkClient(args)
            bc.start()
            bc.join()
            print('time used: %.3f' % bc.avg_time)
        server.join()