34 lines
740 B
Python
34 lines
740 B
Python
import random
|
|
import time
|
|
|
|
import numpy as np
|
|
|
|
import scgenerator as sc
|
|
|
|
SIZE = 100
|
|
|
|
|
|
def compute_stuff(num: int, pbar: sc.threading.Multibar):
|
|
speed = random.random() * 5
|
|
out = 0
|
|
for i in pbar(range(SIZE), desc=f"num {num}"):
|
|
# time.sleep(0.01 * speed * random.random())
|
|
out += np.abs(np.subtract.outer(np.random.rand(1 << 13), np.random.rand(1 << 13))).min()
|
|
if i == 32:
|
|
pbar.print(f"reached 32 in {num}")
|
|
# if random.random() > 0.98:
|
|
# print(f"some text {i}")
|
|
return out
|
|
|
|
|
|
def main():
|
|
data = sc.threading.apply_with_progress(
|
|
compute_stuff, range(12), n_cpu=4, unpack=False, n_pertask=SIZE
|
|
)
|
|
|
|
print(data)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|