from concurrent.futures import ProcessPoolExecutor
import time
class Foo():
def __init__(self, name):
self.name = name
self.start = time.time()
def log(self):
for i in range(1000):
time.sleep(0.001)
print(f"{self.name} - Processing time: {(time.time() - self.start)}")
class Bar():
def __init__(self, name):
self.name = name
self.start = time.time()
def log(self):
for i in range(1000):
time.sleep(0.001)
print(f"{self.name} - Processing time: {(time.time() - self.start)}")
class FooBar():
def __init__(self, name):
self.name = name
self.start = time.time()
def log(self):
for i in range(1000):
time.sleep(0.001)
print(f"{self.name} - Processing time: {(time.time() - self.start)}")
def main():
c1 = Foo("1")
c2 = Foo("2")
c3 = Bar("3")
c4 = Bar("4")
c5 = FooBar("5")
c6 = FooBar("6")
with ProcessPoolExecutor(max_workers=12) as executor:
executor.submit(c1.log)
executor.submit(c2.log)
executor.submit(c3.log)
executor.submit(c4.log)
executor.submit(c5.log)
executor.submit(c6.log)
if __name__ == "__main__":
main()
Ма c завершает каждый вызов журнала за ~ 1.18 с, windows занимает ~ 15,71 с за каждый вызов. Ma c имеет 6 ядер 2.6 ГГц pro c, а Windows имеет 6 ядер 2.4 ГГц pro c.
Почему windows выполнение той же программы почти в 15 раз медленнее?