File: new_documents_multi.py

package info (click to toggle)
ezdxf 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 104,528 kB
  • sloc: python: 182,341; makefile: 116; lisp: 20; ansic: 4
file content (24 lines) | stat: -rw-r--r-- 504 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#  Copyright (c) 2021, Manfred Moitzi
#  License: MIT License

import time
import ezdxf
from multiprocessing import Pool, cpu_count


def work():
    ezdxf.new()


if __name__ == '__main__':
    cpu = cpu_count()
    N = 10000

    print(f"create {N} DXF drawings in {cpu} subprocesses")
    t0 = time.perf_counter()
    with Pool(processes=cpu) as pool:
        for _ in range(N):
            pool.apply(work)

    t = time.perf_counter() - t0
    print(f"created {int(N / t)} DXF drawings per second")