Title: concurrency examples · Issue #43 · fluentpython/example-code-2e · GitHub
Open Graph Title: concurrency examples · Issue #43 · fluentpython/example-code-2e
X Title: concurrency examples · Issue #43 · fluentpython/example-code-2e
Description: hi. so i know that you probably know this but if there will be a 3rd edition, exapmles 19-13 and 19-12 (and other examples in chapter 19) need a rework. e.g the mentioned examples actually fail to prove the point of multiprocessing being...
Open Graph Description: hi. so i know that you probably know this but if there will be a 3rd edition, exapmles 19-13 and 19-12 (and other examples in chapter 19) need a rework. e.g the mentioned examples actually fail to ...
X Description: hi. so i know that you probably know this but if there will be a 3rd edition, exapmles 19-13 and 19-12 (and other examples in chapter 19) need a rework. e.g the mentioned examples actually fail to ...
Opengraph URL: https://github.com/fluentpython/example-code-2e/issues/43
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"concurrency examples","articleBody":"hi.\r\nso i know that you probably know this\r\nbut if there will be a 3rd edition, exapmles 19-13 and 19-12 (and other examples in chapter 19) need a rework.\r\ne.g the mentioned examples actually fail to prove the point of multiprocessing being good for cpu bound work since the prime number example is done in less than a second\r\nthe perf_countr() actually shows `0.00`\r\nand 19-13 actually takes longer due to multiprocessing overhead\r\n\r\nbelow is the result of running them on python 3.12.2 on a not very new xeon cpu with `perf_counter()`\r\n```\r\npython sequential.py \r\n\r\nChecking 20 numbers sequentially:\r\n 2 P 0.000001s\r\n 142702110479723 P 0.000002s\r\n 299593572317531 P 0.000001s\r\n3333333333333301 P 0.000001s\r\n3333333333333333 P 0.000001s\r\n3333335652092209 P 0.000001s\r\n4444444444444423 P 0.000001s\r\n4444444444444444 0.000001s\r\n4444444488888889 P 0.000001s\r\n5555553133149889 P 0.000001s\r\n5555555555555503 P 0.000001s\r\n5555555555555555 P 0.000001s\r\n6666666666666666 0.000001s\r\n6666666666666719 P 0.000001s\r\n6666667141414921 P 0.000001s\r\n7777777536340681 P 0.000001s\r\n7777777777777753 P 0.000001s\r\n7777777777777777 P 0.000001s\r\n9999999999999917 P 0.000001s\r\n9999999999999999 P 0.000001s\r\nTotal time: 0.00s\r\n```\r\n```\r\npython procs.py \r\n\r\nCheking 20 numbers with 16 processes:\r\n 2 P 0.000035s\r\n 142702110479723 P 0.000003s\r\n 299593572317531 P 0.000002s\r\n3333333333333301 P 0.000001s\r\n3333333333333333 P 0.000001s\r\n3333335652092209 P 0.000001s\r\n4444444444444423 P 0.000001s\r\n4444444444444444 0.000001s\r\n4444444488888889 P 0.000001s\r\n5555555555555503 P 0.000001s\r\n5555555555555555 P 0.000001s\r\n6666666666666666 0.000001s\r\n6666666666666719 P 0.000001s\r\n6666667141414921 P 0.000001s\r\n7777777536340681 P 0.000001s\r\n7777777777777753 P 0.000001s\r\n7777777777777777 P 0.000001s\r\n9999999999999917 P 0.000001s\r\n9999999999999999 P 0.000001s\r\n5555553133149889 P 0.000033s\r\n20 checks in 0.02s\r\n```\r\n\r\nand this is the result using `perf_counter_ns()`\r\n\r\n```\r\npython sequential.py \r\n\r\nChecking 20 numbers sequentially:\r\n 2 P 487.000000ns\r\n 142702110479723 P 1047.000000ns\r\n 299593572317531 P 500.000000ns\r\n3333333333333301 P 320.000000ns\r\n3333333333333333 P 295.000000ns\r\n3333335652092209 P 279.000000ns\r\n4444444444444423 P 214.000000ns\r\n4444444444444444 296.000000ns\r\n4444444488888889 P 215.000000ns\r\n5555553133149889 P 200.000000ns\r\n5555555555555503 P 222.000000ns\r\n5555555555555555 P 247.000000ns\r\n6666666666666666 290.000000ns\r\n6666666666666719 P 196.000000ns\r\n6666667141414921 P 227.000000ns\r\n7777777536340681 P 202.000000ns\r\n7777777777777753 P 202.000000ns\r\n7777777777777777 P 202.000000ns\r\n9999999999999917 P 202.000000ns\r\n9999999999999999 P 202.000000ns\r\nTotal time: 118353.00ns\r\n```\r\n```\r\npython procs.py \r\n\r\nCheking 20 numbers with 16 processes:\r\n 2 P 13804.000000ns\r\n 142702110479723 P 2860.000000ns\r\n 299593572317531 P 1762.000000ns\r\n3333333333333301 P 1324.000000ns\r\n3333333333333333 P 1270.000000ns\r\n3333335652092209 P 1073.000000ns\r\n4444444444444423 P 794.000000ns\r\n4444444444444444 1200.000000ns\r\n4444444488888889 P 810.000000ns\r\n5555553133149889 P 890.000000ns\r\n5555555555555503 P 753.000000ns\r\n5555555555555555 P 995.000000ns\r\n6666666666666666 925.000000ns\r\n6666666666666719 P 813.000000ns\r\n6666667141414921 P 678.000000ns\r\n7777777536340681 P 763.000000ns\r\n7777777777777753 P 703.000000ns\r\n9999999999999917 P 941.000000ns\r\n9999999999999999 P 740.000000ns\r\n7777777777777777 P 26330.000000ns\r\n20 checks in 18213477.00ns\r\n```","author":{"url":"https://github.com/amirreza8002","@type":"Person","name":"amirreza8002"},"datePublished":"2024-04-10T22:48:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/43/example-code-2e/issues/43"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e2ecbadd-128c-2eaa-e911-95b48965ce3d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E020:8F24B:10786E9:16E2728:6970C6D1 |
| html-safe-nonce | a455e4731fb0bb5a70ef65909170eafb13bdc680abf36c46736b7fb30d6be172 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDIwOjhGMjRCOjEwNzg2RTk6MTZFMjcyODo2OTcwQzZEMSIsInZpc2l0b3JfaWQiOiI0OTIwMDQxNTEzNTg1NTI2NDgxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b4ef90980cbe4339c82b57481d41a3504e80ca2208b9d5dd54ffa4f792ff4cfa |
| hovercard-subject-tag | issue:2236552600 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/fluentpython/example-code-2e/43/issue_layout |
| twitter:image | https://opengraph.githubassets.com/23abc33981582a1e5f7bf25a9b36d841d7cd490554ae9df6fdbe0c24a707f680/fluentpython/example-code-2e/issues/43 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/23abc33981582a1e5f7bf25a9b36d841d7cd490554ae9df6fdbe0c24a707f680/fluentpython/example-code-2e/issues/43 |
| og:image:alt | hi. so i know that you probably know this but if there will be a 3rd edition, exapmles 19-13 and 19-12 (and other examples in chapter 19) need a rework. e.g the mentioned examples actually fail to ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | amirreza8002 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 721764876e433c894814212f8100f6610f1dde78a987acc2e385d8be8e170e9c |
| turbo-cache-control | no-preview |
| go-import | github.com/fluentpython/example-code-2e git https://github.com/fluentpython/example-code-2e.git |
| octolytics-dimension-user_id | 9216311 |
| octolytics-dimension-user_login | fluentpython |
| octolytics-dimension-repository_id | 176997413 |
| octolytics-dimension-repository_nwo | fluentpython/example-code-2e |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 176997413 |
| octolytics-dimension-repository_network_root_nwo | fluentpython/example-code-2e |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6ff3d08f4ee1c3f89ebedf4df8fc8fe851190294 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width