def test5():
    print("Test con k differenti. Input random(0,{}). Lista di {} elementi.\n".
          format(amount, amount))

    basel = [randint(0, 1 << 32) for i in range(amount)]  # @UnusedVariable
    k = int(amount / 2)

    kNumber = 101

    for i in range(1, kNumber):
        k = int(amount / kNumber) * i - 1
        l = list(basel)
        start = time()
        res = Selection.quickSelectDet(l, k, 10)
        elapsed = time() - start
        print('{},{}'.format(k, elapsed))
def test2():
    print(
        "Input ordinato inversamente. Lista di {} elementi.\n".format(amount))

    l = list(range(amount, -1, -1))
    start = time()
    res = Selection.sortSelect(l, k)
    elapsed = time() - start
    print("sortSelect takes {} seconds. Selected element in position {} is {}".
          format(elapsed, k, res))

    l = list(range(amount, -1, -1))
    start = time()
    res = Selection.heapSelect(l, k)
    elapsed = time() - start
    print("heapSelect takes {} seconds. Selected element in position {} is {}".
          format(elapsed, k, res))

    l = list(range(amount, -1, -1))
    start = time()
    res = Selection.quickSelectRand(l, k)
    elapsed = time() - start
    print(
        "quickSelectRand takes {} seconds. Selected element in position {} is {}"
        .format(elapsed, k, res))

    l = list(range(amount, -1, -1))
    minLen = 0
    start = time()
    res = Selection.quickSelectDet(l, k, minLen)
    elapsed = time() - start
    print(
        "quickSelectDet (with minLen={}) takes {} seconds. Selected element in position {} is {}"
        .format(minLen, elapsed, k, res))

    l = list(range(amount, -1, -1))
    minLen = 15
    start = time()
    res = Selection.quickSelectDet(l, k, minLen)
    elapsed = time() - start
    print(
        "quickSelectDet (with minLen={}) takes {} seconds. Selected element in position {} is {}"
        .format(minLen, elapsed, k, res))

    l = list(range(amount, -1, -1))
    minLen = 30
    start = time()
    res = Selection.quickSelectDet(l, k, minLen)
    elapsed = time() - start
    print(
        "quickSelectDet (with minLen={}) takes {} seconds. Selected element in position {} is {}"
        .format(minLen, elapsed, k, res))

    if trivial:
        l = list(range(amount, -1, -1))
        start = time()
        res = Selection.trivialSelect(l, k)
        elapsed = time() - start
        print(
            "trivialSelect takes {} seconds. Selected element in position {} is {}"
            .format(elapsed, k, res))

    print("\nEnd.")
def test1():
    print("Input gia' ordinato. Lista di {} elementi.\n".format(amount))

    # ATT: in Python v. < 3 è sufficiente l = range(amount) perché range è una lista.
    #      in Python v. >= 3 range è un tipo di dato a parte da trasformare in lista.
    l = list(range(amount))
    start = time()
    res = Selection.sortSelect(l, position)
    elapsed = time() - start
    print("sortSelect takes {} seconds. Selected element in position {} is {}".
          format(elapsed, position, res))

    l = list(range(amount))
    start = time()
    res = Selection.heapSelect(l, position)
    elapsed = time() - start
    print("heapSelect takes {} seconds. Selected element in position {} is {}".
          format(elapsed, position, res))

    l = list(range(amount))
    start = time()
    res = Selection.quickSelectRand(l, position)
    elapsed = time() - start
    print(
        "quickSelectRand takes {} seconds. Selected element in position {} is {}"
        .format(elapsed, position, res))

    l = list(range(amount))
    minLen = 0
    start = time()
    res = Selection.quickSelectDet(l, position, minLen)
    elapsed = time() - start
    print(
        "quickSelectDet (with minLen={}) takes {} seconds. Selected element in position {} is {}"
        .format(minLen, elapsed, position, res))

    l = list(range(amount))
    minLen = 15
    start = time()
    res = Selection.quickSelectDet(l, position, minLen)
    elapsed = time() - start
    print(
        "quickSelectDet (with minLen={}) takes {} seconds. Selected element in position {} is {}"
        .format(minLen, elapsed, position, res))

    l = list(range(amount))
    minLen = 30
    start = time()
    res = Selection.quickSelectDet(l, position, minLen)
    elapsed = time() - start
    print(
        "quickSelectDet (with minLen={}) takes {} seconds. Selected element in position {} is {}"
        .format(minLen, elapsed, position, res))

    if trivial:
        l = list(range(amount))
        start = time()
        res = Selection.trivialSelect(l, k)
        elapsed = time() - start
        print(
            "trivialSelect takes {} seconds. Selected element in position {} is {}"
            .format(elapsed, k, res))

    print("\nEnd.")
def test3():
    print("Input random(0,{}). Lista di {} elementi.\n".format(amount, amount))

    basel = [randint(0, amount) for i in range(amount)]  # @UnusedVariable
    l = list(basel)
    start = time()
    res = Selection.sortSelect(l, k)
    elapsed = time() - start
    print("sortSelect takes {} seconds. Selected element in position {} is {}".
          format(elapsed, k, res))

    l = list(basel)
    start = time()
    res = Selection.heapSelect(l, k)
    elapsed = time() - start
    print("heapSelect takes {} seconds. Selected element in position {} is {}".
          format(elapsed, k, res))

    l = list(basel)
    start = time()
    res = Selection.quickSelectRand(l, k)
    elapsed = time() - start
    print(
        "quickSelectRand takes {} seconds. Selected element in position {} is {}"
        .format(elapsed, k, res))

    l = list(basel)
    minLen = 0
    start = time()
    res = Selection.quickSelectDet(l, k, minLen)
    elapsed = time() - start
    print(
        "quickSelectDet (with minLen={}) takes {} seconds. Selected element in position {} is {}"
        .format(minLen, elapsed, k, res))

    l = list(basel)
    minLen = 5
    start = time()
    res = Selection.quickSelectDet(l, k, minLen)
    elapsed = time() - start
    print(
        "quickSelectDet (with minLen={}) takes {} seconds. Selected element in position {} is {}"
        .format(minLen, elapsed, k, res))

    l = list(basel)
    minLen = 30
    start = time()
    res = Selection.quickSelectDet(l, k, minLen)
    elapsed = time() - start
    print(
        "quickSelectDet (with minLen={}) takes {} seconds. Selected element in position {} is {}"
        .format(minLen, elapsed, k, res))

    if trivial:
        l = list(basel)
        start = time()
        res = Selection.trivialSelect(l, k)
        elapsed = time() - start
        print(
            "trivialSelect takes {} seconds. Selected element in position {} is {}"
            .format(elapsed, k, res))

    print("\nEnd.")