File: test_python_simple.py

package info (click to toggle)
python-parsl 2025.01.13%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,072 kB
  • sloc: python: 23,817; makefile: 349; sh: 276; ansic: 45
file content (43 lines) | stat: -rw-r--r-- 1,007 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import argparse
import time

import parsl
from parsl import python_app
from parsl.configs.htex_local import config


@python_app
def increment(x):
    return x + 1


def test_stress(count=1000):
    """Threaded app RTT stress test"""

    start = time.time()
    x = []
    for i in range(count):
        f = increment(i)
        x.append(f)
    end = time.time()
    print("Launched {0} tasks in {1:.2f} s".format(count, end - start))

    [f.result() for f in x]
    end = time.time()
    print("Completed {0} tasks in {1:.2f} s".format(count, end - start))


if __name__ == '__main__':
    parsl.load(config)

    parser = argparse.ArgumentParser()
    parser.add_argument("-c", "--count", type=int, default=1000,
                        help="width of the pipeline")
    parser.add_argument("-d", "--debug", action='store_true',
                        help="Enable stream logging")
    args = parser.parse_args()

    if args.debug:
        parsl.set_stream_logger()

    test_stress(count=args.count)