Exemple #1
0
def test_1_05_2():
    make(9)
    a = (2**138 - 134521) * (2**364 + 9999)
    b = (2**138 - 134521) * (2**612 + 777)
    input = split8.split8(a)
    input += "\n"
    input += split8.split8(b)
    # 値チェック
    print("1_05_2_check")
    out = run_command(input).splitlines()[-1].rstrip()
    #print(out)
    #print(split8.split8_format(math.gcd(a, b)).rstrip())
    if out == split8.split8_format(math.gcd(a, b)).rstrip():
        print("OK")
    else:
        print("NG")
        return
    # 性能評価
    print("1_05_2_time")
    with open("csv\\1_05_2_time.csv", mode="w") as output:
        output.write("count,time\n")
        for i in [10, 100, 1000]:
            start = time.time()
            for j in range(0, i):
                out = run_command(input)
            end = time.time() - start
            output.write("{},{}s\n".format(i, end))
    return
Exemple #2
0
def test_1_04_2():
    # 値チェック
    print("1_04_2_check")
    n1 = 2**1023
    n2 = 2**345 - 1
    make(6)
    input = "{}\n{}".format(split8.split8(n1), split8.split8(n2))
    out = run_command(input)
    quo = out.splitlines()[-2].rstrip()
    rem = out.splitlines()[-1].rstrip()
    make(7)
    out = run_command(input)
    if out.splitlines()[-2].rstrip() == quo and out.splitlines()[-1].rstrip(
    ) == rem:
        print("OK")
    else:
        print("NG")
        return
    # 性能評価
    print("1_04_2_time")
    with open("csv\\1_04_2_time.csv", mode="w") as output:
        output.write("func,count,time\n")
        for mode in [6, 7]:
            make(mode)
            for i in [10, 100, 1000]:
                start = time.time()
                for j in range(0, i):
                    out = run_command(input)
                end = time.time() - start
                output.write("div{},{},{}s\n".format(mode - 3, i, end))
    return
Exemple #3
0
def test_1_03_2():
    # 値チェック
    print("1_03_2_check")
    n1s = [2**651, 2**1023]
    n2s = [14352133, 2**23 + 1]
    make(5)
    for n1, n2 in zip(n1s, n2s):
        input = "{}\n{}".format(split8.split8(n1), split8.split8(n2))
        quo = split8.split8_format(n1 // n2)
        rem = split8.split8_format(n1 % n2)
        out = run_command(input)
        if out.splitlines()[-2].rstrip() == quo and out.splitlines(
        )[-1].rstrip() == rem:
            print("OK")
        else:
            print("NG")
            return
    # 性能評価
    print("1_03_2_time")
    input = "{}\n{}".format(split8.split8(n1s[0]), split8.split8(n2s[0]))
    with open("csv\\1_03_2_time.csv", mode="w") as output:
        output.write("count,time\n")
        for i in [10, 100, 1000]:
            start = time.time()
            for j in range(0, i):
                out = run_command(input)
            end = time.time() - start
            output.write("{},{}s\n".format(i, end))
    return
Exemple #4
0
def test_1_04_1():
    # 値チェック
    print("1_04_1_check")
    n1 = 2**1023
    n2 = 2**345 - 1
    make(6)
    input = "{}\n{}".format(split8.split8(n1), split8.split8(n2))
    quo = split8.split8_format(n1 // n2)
    rem = split8.split8_format(n1 % n2)
    out = run_command(input)
    if out.splitlines()[-2].rstrip() == quo and out.splitlines()[-1].rstrip(
    ) == rem:
        print("OK")
    else:
        print("NG")
        return
    return