コード例 #1
0
def test_stress(repeat=1000):
    slt = SortedList((random.random() for rpt in range(1000)))

    for rpt in range(repeat):
        action = random.choice(actions)
        action(slt)

        slt._check()

        while len(slt) > 2000:
            # Shorten the sortedlist. This maintains the "jaggedness"
            # of the sublists which helps coverage.
            pos = random.randrange(len(slt._maxes))
            del slt._maxes[pos]
            del slt._lists[pos]
            slt._len = sum(len(sublist) for sublist in slt._lists)
            slt._index = []
            slt._check()

    slt._check()

    stress_update(slt)

    while len(slt) > 0:
        pos = random.randrange(len(slt))
        del slt[pos]

    slt._check()
コード例 #2
0
def test_stress(repeat=1000):
    slt = SortedList((random.random() for rpt in range(1000)))

    for rpt in range(repeat):
        action = random.choice(actions)
        action(slt)

        slt._check()

        while len(slt) > 2000:
            # Shorten the sortedlist. This maintains the "jaggedness"
            # of the sublists which helps coverage.
            pos = random.randrange(len(slt._maxes))
            del slt._maxes[pos]
            del slt._lists[pos]
            slt._len = sum(len(sublist) for sublist in slt._lists)
            slt._index = []
            slt._check()

    slt._check()

    stress_update(slt)

    while len(slt) > 0:
        pos = random.randrange(len(slt))
        del slt[pos]

    slt._check()
コード例 #3
0
def test_stress(repeat=1000):
    slt = SortedList((random.random() for rpt in range(1000)))
    slt._reset(23)

    for rpt in range(repeat):
        action = random.choice(actions)
        action(slt)

        slt._check()

        fourth = int(len(slt) / 4)
        count = 0 if fourth == 0 else random.randrange(-fourth, fourth)

        while count > 0:
            slt.add(random.random())
            count -= 1

        while count < 0:
            pos = random.randrange(len(slt))
            del slt[pos]
            count += 1

        while len(slt) > 2000:
            # Shorten the sortedlist. This maintains the "jaggedness"
            # of the sublists which helps coverage.
            pos = random.randrange(len(slt._maxes))
            del slt._maxes[pos]
            del slt._lists[pos]
            slt._len = sum(len(sublist) for sublist in slt._lists)
            slt._index = []
            slt._check()

        slt._check()

    slt._check()

    stress_update(slt)

    while len(slt) > 0:
        pos = random.randrange(len(slt))
        del slt[pos]

    slt._check()
コード例 #4
0
def test_stress(repeat=1000):
    slt = SortedList((random.random() for rpt in range(1000)))
    slt._reset(23)

    for rpt in range(repeat):
        action = random.choice(actions)
        action(slt)

        slt._check()

        fourth = int(len(slt) / 4)
        count = 0 if fourth == 0 else random.randrange(-fourth, fourth)

        while count > 0:
            slt.add(random.random())
            count -= 1

        while count < 0:
            pos = random.randrange(len(slt))
            del slt[pos]
            count += 1

        while len(slt) > 2000:
            # Shorten the sortedlist. This maintains the "jaggedness"
            # of the sublists which helps coverage.
            pos = random.randrange(len(slt._maxes))
            del slt._maxes[pos]
            del slt._lists[pos]
            slt._len = sum(len(sublist) for sublist in slt._lists)
            slt._index = []
            slt._check()

        slt._check()

    slt._check()

    stress_update(slt)

    while len(slt) > 0:
        pos = random.randrange(len(slt))
        del slt[pos]

    slt._check()