def main():
    math_core.do_math(1)

    print("Doing math on {:,} processors.".format(multiprocessing.cpu_count()))

    processor_count = multiprocessing.cpu_count()
    threads = []
    for n in range(1, processor_count + 1):
        threads.append(
            Thread(
                target=math_core.do_math,
                args=(
                    3_000_000 * (n - 1) / processor_count,
                    3_000_000 * n / processor_count,
                ),
                daemon=True,
            )
        )

    t0 = datetime.datetime.now()
    [t.start() for t in threads]

    [t.join() for t in threads]
    # math_core.do_math(num=300_000)

    dt = datetime.datetime.now() - t0
    print(
        "Done in {:,.2f} sec. (factor: {:,.2f}x)".format(
            dt.total_seconds(), 0.80 / dt.total_seconds()
        )
    )
예제 #2
0
def main():
    math_core.do_math(1)

    t0 = datetime.datetime.now()

    print("Doing math on {:,} processors".format(multiprocessing.cpu_count()))

    processor_count = multiprocessing.cpu_count()
    threads = []
    for i in range(1, processor_count + 1):
        threads.append(
            Thread(
                target=math_core.do_math,
                args=(
                    30_000_000 * (i - 1) / processor_count,
                    30_000_000 * i / processor_count,
                ),
                daemon=True,
            ))

    [t.start() for t in threads]
    [t.join() for t in threads]

    dt = datetime.datetime.now() - t0
    print("Done in {:,.2f} sec".format(dt.total_seconds()))
예제 #3
0
def main():
    math_core.do_math(1)

    # do_math(num=30000000)
    processor_count = multiprocessing.cpu_count()
    print('Doing math on {:,} processors.'.format(multiprocessing.cpu_count()))
    threads = []
    for n in range(1, processor_count + 1):
        threads.append(
            (threading.Thread(target=math_core.do_math, args=(300_000 * (n - 1) / processor_count,
                                                              300_000 * n / processor_count),
                              daemon=True))
        )
    t0 = datetime.datetime.now()

    [t.start() for t in threads]
    [t.join() for t in threads]

    dt = datetime.datetime.now() - t0
    print('Done in {:,.2f} sec.'.format(dt.total_seconds()))