diff --git a/REPORT.md b/REPORT.md new file mode 100644 index 0000000..cd93a0f --- /dev/null +++ b/REPORT.md @@ -0,0 +1,35 @@ +# Первое задание +### Синхронная проверка 100 ссылок (время работы - 185938ms) +![](screenshots/first_profile.png) + +### 5 воркеров (время работы - 36440ms) +![](screenshots/5_workers.jpg) + +### 10 воркеров (время работы - 24527ms) +![](screenshots/10_workers.jpg) + +### 100 воркеров (время работы - 18519ms) +![](screenshots/100_workers.jpg) + +#### Используя ThreadPoolExecutor, можно значительно увеличть скорость проверки ссылок. +#### Изменение количества воркеров существенно не влияет на загрузку памяти, процессора. Однако увеличение количества воркеров приводит к уменьшению времени работы программы и увелечению активности отправки и получения в сети. + +# Второе задание +#### Генерация одной монеты на одном ядре в среднем занимает 40000 - 60000ms. + +### 2 воркера (время генерации пяти монет - 29878ms) +![](screenshots/2_workers2.jpg) + +### 4 воркера (время генерации пяти монет - 27118ms) +![](screenshots/4_workers2.jpg) + +### 5 воркеров (время генерации пяти монет - 24082ms) +![](screenshots/5_workers2.jpg) + +### 10 воркеров (время генерации пяти монет - 26401ms) +![](screenshots/10_workers2.jpg) + +### 61 воркер (время генерации пяти монет - 24223ms) +![](screenshots/61_workers2.jpg) + +#### Изменение количества воркеров влияет на загрузку памяти и процессора. Максимальное количество воркеров - 61 (ограничение ОС). Увеличение скорости генерации монет будет происходить, пока количество воркеров не превышает число ядер процессора. При 10 и 61 воркерах не происходит увеличение скорости генерации, так как у процессора всего 6 ядер. \ No newline at end of file diff --git a/generating coins.py b/generating coins.py new file mode 100644 index 0000000..266f149 --- /dev/null +++ b/generating coins.py @@ -0,0 +1,23 @@ +from hashlib import md5 +from random import choice +import concurrent.futures + + +def generate_coin(c): + while True: + s = "".join([choice("0123456789") for i in range(50)]) + h = md5(s.encode('utf8')).hexdigest() + if h.endswith("00000"): + c = f"{s} {h}" + break + return c + + +def main(): + with concurrent.futures.ProcessPoolExecutor(max_workers=5) as executor: + for coin in zip(executor.map(generate_coin, [0, 0, 0, 0, 0])): + print(coin) + + +if __name__ == '__main__': + main() diff --git a/link checking.py b/link checking.py new file mode 100644 index 0000000..356118b --- /dev/null +++ b/link checking.py @@ -0,0 +1,26 @@ +from urllib.request import Request, urlopen +import concurrent.futures + + +def get_wiki_page_existence(wiki_page_url): + request = Request( + wiki_page_url, + headers={'User-Agent': 'Mozilla/5.0 (Windows NT 9.0; Win65; x64; rv:97.0) Gecko/20105107 Firefox/92.0'}, + ) + resp = urlopen(request, timeout=100) + code = resp.code + resp.close() + return code + + +links = open('res.txt', encoding='utf8').read().split('\n') + +with concurrent.futures.ThreadPoolExecutor(max_workers=61) as executor: + futures = [] + for url in links: + futures.append(executor.submit(get_wiki_page_existence, url)) + for future in concurrent.futures.as_completed(futures): + try: + print(future.result()) + except Exception as e: + print(url, e) diff --git a/res.txt b/res.txt new file mode 100644 index 0000000..1f3571e --- /dev/null +++ b/res.txt @@ -0,0 +1,100 @@ +http://warintheaeneid.umwblogs.org/2008/06/13/deception-in-the-aeneid/ +https://www.nasa.gov/mission_pages/juno/news/juno20110805.html +http://warburg.sas.ac.uk/vpc/VPC_search/subcats.php?cat_1=5&cat_2=48 +https://d-nb.info/gnd/118800574 +https://viaf.org/viaf/47558229 +https://www.worldcat.org/identities/viaf-47558229 +https://id.loc.gov/authorities/names/no2016066396 +https://www.idref.fr/028557697 +http://warintheaeneid.umwblogs.org/2008/06/13/deception-in-the-aeneid/ +https://www.nasa.gov/mission_pages/juno/news/juno20110805.html +http://warburg.sas.ac.uk/vpc/VPC_search/subcats.php?cat_1=5&cat_2=48 +https://d-nb.info/gnd/118800574 +https://viaf.org/viaf/47558229 +https://www.worldcat.org/identities/viaf-47558229 +https://id.loc.gov/authorities/names/no2016066396 +https://www.idref.fr/028557697 +http://warintheaeneid.umwblogs.org/2008/06/13/deception-in-the-aeneid/ +https://www.nasa.gov/mission_pages/juno/news/juno20110805.html +http://warburg.sas.ac.uk/vpc/VPC_search/subcats.php?cat_1=5&cat_2=48 +https://d-nb.info/gnd/118800574 +https://viaf.org/viaf/47558229 +https://www.worldcat.org/identities/viaf-47558229 +https://id.loc.gov/authorities/names/no2016066396 +https://www.idref.fr/028557697 +http://warintheaeneid.umwblogs.org/2008/06/13/deception-in-the-aeneid/ +https://www.nasa.gov/mission_pages/juno/news/juno20110805.html +http://warburg.sas.ac.uk/vpc/VPC_search/subcats.php?cat_1=5&cat_2=48 +https://d-nb.info/gnd/118800574 +https://viaf.org/viaf/47558229 +https://www.worldcat.org/identities/viaf-47558229 +https://id.loc.gov/authorities/names/no2016066396 +https://www.idref.fr/028557697 +http://warintheaeneid.umwblogs.org/2008/06/13/deception-in-the-aeneid/ +https://www.nasa.gov/mission_pages/juno/news/juno20110805.html +http://warburg.sas.ac.uk/vpc/VPC_search/subcats.php?cat_1=5&cat_2=48 +https://d-nb.info/gnd/118800574 +https://viaf.org/viaf/47558229 +https://www.worldcat.org/identities/viaf-47558229 +https://id.loc.gov/authorities/names/no2016066396 +https://www.idref.fr/028557697 +http://warintheaeneid.umwblogs.org/2008/06/13/deception-in-the-aeneid/ +https://www.nasa.gov/mission_pages/juno/news/juno20110805.html +http://warburg.sas.ac.uk/vpc/VPC_search/subcats.php?cat_1=5&cat_2=48 +https://d-nb.info/gnd/118800574 +https://viaf.org/viaf/47558229 +https://www.worldcat.org/identities/viaf-47558229 +https://id.loc.gov/authorities/names/no2016066396 +https://www.idref.fr/028557697 +http://warintheaeneid.umwblogs.org/2008/06/13/deception-in-the-aeneid/ +https://www.nasa.gov/mission_pages/juno/news/juno20110805.html +http://warburg.sas.ac.uk/vpc/VPC_search/subcats.php?cat_1=5&cat_2=48 +https://d-nb.info/gnd/118800574 +https://viaf.org/viaf/47558229 +https://www.worldcat.org/identities/viaf-47558229 +https://id.loc.gov/authorities/names/no2016066396 +https://www.idref.fr/028557697 +http://warintheaeneid.umwblogs.org/2008/06/13/deception-in-the-aeneid/ +https://www.nasa.gov/mission_pages/juno/news/juno20110805.html +http://warburg.sas.ac.uk/vpc/VPC_search/subcats.php?cat_1=5&cat_2=48 +https://d-nb.info/gnd/118800574 +https://viaf.org/viaf/47558229 +https://www.worldcat.org/identities/viaf-47558229 +https://id.loc.gov/authorities/names/no2016066396 +https://www.idref.fr/028557697 +http://warintheaeneid.umwblogs.org/2008/06/13/deception-in-the-aeneid/ +https://www.nasa.gov/mission_pages/juno/news/juno20110805.html +http://warburg.sas.ac.uk/vpc/VPC_search/subcats.php?cat_1=5&cat_2=48 +https://d-nb.info/gnd/118800574 +https://viaf.org/viaf/47558229 +https://www.worldcat.org/identities/viaf-47558229 +https://id.loc.gov/authorities/names/no2016066396 +https://www.idref.fr/028557697 +http://warintheaeneid.umwblogs.org/2008/06/13/deception-in-the-aeneid/ +https://www.nasa.gov/mission_pages/juno/news/juno20110805.html +http://warburg.sas.ac.uk/vpc/VPC_search/subcats.php?cat_1=5&cat_2=48 +https://d-nb.info/gnd/118800574 +https://viaf.org/viaf/47558229 +https://www.worldcat.org/identities/viaf-47558229 +https://id.loc.gov/authorities/names/no2016066396 +https://www.idref.fr/028557697 +http://warintheaeneid.umwblogs.org/2008/06/13/deception-in-the-aeneid/ +https://www.nasa.gov/mission_pages/juno/news/juno20110805.html +http://warburg.sas.ac.uk/vpc/VPC_search/subcats.php?cat_1=5&cat_2=48 +https://d-nb.info/gnd/118800574 +https://viaf.org/viaf/47558229 +https://www.worldcat.org/identities/viaf-47558229 +https://id.loc.gov/authorities/names/no2016066396 +https://www.idref.fr/028557697 +http://warintheaeneid.umwblogs.org/2008/06/13/deception-in-the-aeneid/ +https://www.nasa.gov/mission_pages/juno/news/juno20110805.html +http://warburg.sas.ac.uk/vpc/VPC_search/subcats.php?cat_1=5&cat_2=48 +https://d-nb.info/gnd/118800574 +https://viaf.org/viaf/47558229 +https://www.worldcat.org/identities/viaf-47558229 +https://id.loc.gov/authorities/names/no2016066396 +https://www.idref.fr/028557697 +http://warintheaeneid.umwblogs.org/2008/06/13/deception-in-the-aeneid/ +https://www.nasa.gov/mission_pages/juno/news/juno20110805.html +http://warburg.sas.ac.uk/vpc/VPC_search/subcats.php?cat_1=5&cat_2=48 +https://d-nb.info/gnd/118800574 \ No newline at end of file diff --git a/screenshots/100_workers.jpg b/screenshots/100_workers.jpg new file mode 100644 index 0000000..f7af556 Binary files /dev/null and b/screenshots/100_workers.jpg differ diff --git a/screenshots/10_workers.jpg b/screenshots/10_workers.jpg new file mode 100644 index 0000000..1f63c5c Binary files /dev/null and b/screenshots/10_workers.jpg differ diff --git a/screenshots/10_workers2.jpg b/screenshots/10_workers2.jpg new file mode 100644 index 0000000..5649cd0 Binary files /dev/null and b/screenshots/10_workers2.jpg differ diff --git a/screenshots/2_workers2.jpg b/screenshots/2_workers2.jpg new file mode 100644 index 0000000..1d92f92 Binary files /dev/null and b/screenshots/2_workers2.jpg differ diff --git a/screenshots/4_workers2.jpg b/screenshots/4_workers2.jpg new file mode 100644 index 0000000..c562dfb Binary files /dev/null and b/screenshots/4_workers2.jpg differ diff --git a/screenshots/5_workers.jpg b/screenshots/5_workers.jpg new file mode 100644 index 0000000..fdaf8de Binary files /dev/null and b/screenshots/5_workers.jpg differ diff --git a/screenshots/5_workers2.jpg b/screenshots/5_workers2.jpg new file mode 100644 index 0000000..2195ee9 Binary files /dev/null and b/screenshots/5_workers2.jpg differ diff --git a/screenshots/61_workers2.jpg b/screenshots/61_workers2.jpg new file mode 100644 index 0000000..d98412c Binary files /dev/null and b/screenshots/61_workers2.jpg differ diff --git a/screenshots/first_profile.png b/screenshots/first_profile.png new file mode 100644 index 0000000..a2515e2 Binary files /dev/null and b/screenshots/first_profile.png differ