Exemplo n.º 1
0
def test_sat_subprotocol_performance(PurchaseComposition):
    t = Timer()
    print("SAT (components): ")
    print('Protocol, Property, Min, Mean, Max')

    for P in PurchaseComposition.protocols.values():
        if 'Commerce' in P.name:
            continue
        properties = {
            "Enactability": P.is_enactable,
            "Liveness": P.is_live,
            "Safety": P.is_safe
        }
        for name, fn in properties.items():
            times = []
            for x in range(10):
                t.tic()
                fn()
                t.toc()
                print(t.elapsed)
                times.append(t.elapsed * 1000)  # use milliseconds
            mean = sum(times) / len(times)
            print(
                f"{P.name}, {name}, {int(min(times))}, {int(mean)}, {int(max(times))}"
            )
Exemplo n.º 2
0
def test_single_sub_performance(PurchaseComposition):
    t = Timer()
    print("SAT (single sub): ")
    print('Protocol, Property, Min, Mean, Max, Times')

    specs = [
        'sub-buyer-starts.bspl', 'sub-pay-first.bspl', 'sub-single-lookup.bspl'
    ]

    for s in specs:
        P = load_file('samples/bspl/performance/' +
                      s).protocols['Refined-Commerce']
        properties = {"Liveness": P.is_live, "Safety": P.is_safe}
        for name, fn in properties.items():
            times = []
            for x in range(10 + 1):
                t.tic()
                fn()
                t.toc()
                if x > 0:  # burn in once
                    times.append(t.elapsed * 1000)  # use milliseconds
            mean = sum(times) / len(times)
            print(
                f"{s}, {name}, {int(min(times))}, {int(mean)}, {int(max(times))}, {times}"
            )
Exemplo n.º 3
0
def consistent(*statements, exhaustive=False):
    options = arg_parser.parse_known_args()[0]  # apparently returns a tuple
    stats["statements"] += logic.count(statements)
    statements = [logic.compile(s) for s in statements]

    clauses = statements
    cons = []
    t = Timer()
    t.tic()
    if options.exhaustive or exhaustive:
        cons += exhaustive_consistency(statements)
        result = solve(clauses + cons, options, depth="exhaustive")
    else:
        depth = int(options.depth)
        for d in range(depth):
            cons = consistency(clauses + cons)
        result = solve(clauses + cons, options, depth)
        while result and cycle(result):
            depth += 1
            cons = consistency(clauses + cons)
            result = solve(clauses + cons, options, depth)
    t.toc()
    stats["time"] += t.elapsed

    return result
Exemplo n.º 4
0
def perf_test(objects, properties):
    t = Timer()
    for obj in objects:
        for name, fn in properties.items():
            times = []
            for x in range(10 + 1):
                t.tic()
                fn(obj)
                t.toc()
                if x > 0:  # burn in once
                    times.append(t.elapsed * 1000)  # use milliseconds
            mean = sum(times) / len(times)
            print(
                f"{obj.name}, {name}, {int(min(times))}, {int(mean)}, {int(max(times))}, {times}"
            )
Exemplo n.º 5
0
def test_refinement_performance(PurchaseComposition):
    t = Timer()
    print("Refinement: ")
    print("Protocol, Min, Avg, Max")
    Ps = ['Either-Starts', 'Lookup-Prices', 'Flexible-Payment']
    Qs = ['Buyer-Starts', 'Single-Lookup', 'Pay-First']
    for i, name in enumerate(Ps):
        P = PurchaseComposition.protocols[Ps[i]]
        Q = PurchaseComposition.protocols[Qs[i]]
        times = []
        for x in range(10):
            t.tic()
            refines(UoD(), P.public_parameters, Q, P)
            t.toc()
            times.append(t.elapsed * 1000)
        avg = sum(times) / len(times)
        print(
            f"{P.name}, {int(min(times))}, {int(avg)}, {int(max(times))}, {times}"
        )