コード例 #1
0
ファイル: demo_11.py プロジェクト: isbjorntrading/aiocells
def main():

    stopwatch = aiocells.Stopwatch()
    graph = create_graph(stopwatch)

    asyncio.run(aiocells.async_compute_concurrent(graph))
    print("Computation with async_compute_concurrent took"
          f" {stopwatch.elapsed_time()}")
コード例 #2
0
ファイル: demo_6.py プロジェクト: isbjorntrading/aiocells
def main():

    stopwatch = aiocells.Stopwatch()
    graph = create_graph(stopwatch)
    # Even though the graph is a diamond (the sleeps do no depend on each
    # other and _could_ be executed concurrenty, `async_compute_sequential`
    # does not support concurrent execution. Thus, the execution time is
    # about 3 seconds, the sum of the two sleeps.
    print("Two async sleeps computed sequentially.")
    print("Total time should take about 3 seconds...")
    asyncio.run(aiocells.async_compute_sequential(graph))
    print("Computation with `async_compute_sequential` took"
          f" {stopwatch.elapsed_time()}")
コード例 #3
0
def main():

    stopwatch = aiocells.Stopwatch()
    graph = create_graph(stopwatch)

    print("Should take about 3 seconds...")
    asyncio.run(aiocells.async_compute_concurrent_simple(graph))
    print("Computation with `async_compute_concurrent_simple` took "
          f"{stopwatch.elapsed_time()}")

    print("Should take about 3 seconds...")
    asyncio.run(aiocells.async_compute_concurrent(graph))
    print("Computation with `async_compute_concurrent` took "
          f"{stopwatch.elapsed_time()}")
コード例 #4
0
def main():
    stopwatch = aiocells.Stopwatch()
    graph = demo_6.create_graph(stopwatch)

    # Here, we run the same graph as the previous demo but we use
    # 'async_compute_concurrent' which will run the two sleeps concurrently.
    # Thus, the execution time will be around 2 seconds, the maximum of
    # the two sleeps.

    print("Running previous demo's graph concurrently.")
    print("Total execution time should be about 2 seconds...")
    asyncio.run(aiocells.async_compute_concurrent(graph))
    print("Computation with `async_compute_concurrent` took"
          f" {stopwatch.elapsed_time()}")
コード例 #5
0
ファイル: demo_10.py プロジェクト: isbjorntrading/aiocells
def main():

    stopwatch = aiocells.Stopwatch()
    graph = create_graph(stopwatch)

    # How long does it take to compute 100000 null callables with
    # async_compute_concurrent_simple?
    asyncio.run(aiocells.async_compute_concurrent_simple(graph))
    print("Computation with async_compute_concurrent_simple took"
          f"{stopwatch.elapsed_time()}")

    # How long does it take to compute 100000 null callables with
    # async_compute_concurrent?
    asyncio.run(aiocells.async_compute_concurrent(graph))
    print("Computation with async_compute_concurrent took"
          f" {stopwatch.elapsed_time()}")
コード例 #6
0
def main():

    stopwatch = aiocells.Stopwatch()
    graph = create_graph(stopwatch)

    # How long does it take to run 100000 async 1 second sleeps with
    # async_compute_concurrent_simple?
    print("Running 100000 async 1 second sleeps with"
          " async_compute_concurrent_simple...")
    asyncio.run(aiocells.async_compute_concurrent_simple(graph))
    print("Computation with `async_compute_concurrent_simple` took"
          f" {stopwatch.elapsed_time()}")

    # How long does it take to run 100000 async 1 second sleeps with
    # async_compute_concurrent?
    print("Running 100000 async 1 second sleeps with"
          " async_compute_concurrent...")
    asyncio.run(aiocells.async_compute_concurrent(graph))
    print("Computation with `async_compute_concurrent` took"
          f" {stopwatch.elapsed_time()}")