예제 #1
0
def main():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--transfers', default=100, type=int)
    parser.add_argument('--nodes', default=10, type=int)
    parser.add_argument('--tokens', default=1, type=int)
    parser.add_argument('--channels-per-node', default=2, type=int)
    parser.add_argument('-p', '--profile', default=False, action='store_true')
    parser.add_argument('--pdb', default=False, action='store_true')
    parser.add_argument('--throughput',
                        dest='throughput',
                        action='store_true',
                        default=True)
    parser.add_argument('--latency', dest='throughput', action='store_false')
    parser.add_argument('--log', action='store_true', default=False)
    args = parser.parse_args()

    if args.log:
        slogging.configure(':DEBUG')

    if args.profile:
        import GreenletProfiler
        GreenletProfiler.set_clock_type('cpu')
        GreenletProfiler.start()

    tokens = [
        sha3('token:{}'.format(number))[:20] for number in range(args.tokens)
    ]

    amount = 10
    apps = setup_apps(
        amount,
        tokens,
        args.transfers,
        args.nodes,
        args.channels_per_node,
    )

    if args.pdb:
        from raiden.utils.debug import enable_greenlet_debugger
        enable_greenlet_debugger()

        try:
            if args.throughput:
                test_throughput(apps, tokens, args.transfers, amount)
            else:
                test_latency(apps, tokens, args.transfers, amount)
        except:  # noqa
            import pdb
            pdb.xpm()
    else:
        if args.throughput:
            test_throughput(apps, tokens, args.transfers, amount)
        else:
            test_latency(apps, tokens, args.transfers, amount)

    if args.profile:
        GreenletProfiler.stop()
        stats = GreenletProfiler.get_func_stats()
        pstats = GreenletProfiler.convert2pstats(stats)

        print_serialization(pstats)
        print_slow_path(pstats)
        print_slow_function(pstats)

        pstats.sort_stats('time').print_stats()
예제 #2
0
def enable_greenlet_debugger(request):
    if request.config.option.usepdb:
        from raiden.utils.debug import enable_greenlet_debugger
        enable_greenlet_debugger()
예제 #3
0
def enable_greenlet_debugger(request):
    if request.config.option.usepdb:
        from raiden.utils.debug import enable_greenlet_debugger
        enable_greenlet_debugger()