Merge pull request #46 from fverdugo/francesc

Fix questions julia_async notebook
This commit is contained in:
Francesc Verdugo 2024-09-12 14:29:32 +02:00 committed by GitHub
commit 0039ea85e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -53,7 +53,7 @@
"end\n", "end\n",
"function why_q2()\n", "function why_q2()\n",
" msg = \"\"\"\n", " msg = \"\"\"\n",
" The time in doing the loop will be almost zero since the loop just schedules 10 tasks, which should be very fast.\n", " The time in doing the loop will be O(1) since the loop just schedules 10 tasks, which should be a (small) constant time independent of n.\n",
" \"\"\"\n", " \"\"\"\n",
" println(msg)\n", " println(msg)\n",
"end\n", "end\n",
@ -758,7 +758,8 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"t = @elapsed @show compute_π(140_000_000)" "n = 140_000_000\n",
"t = @elapsed @show compute_π(n)"
] ]
}, },
{ {
@ -773,7 +774,7 @@
" a) 10*t\n", " a) 10*t\n",
" b) t\n", " b) t\n",
" c) 0.1*t\n", " c) 0.1*t\n",
" d) near 0*t \n" " d) O(1), i.e. time independent from n \n"
] ]
}, },
{ {
@ -783,8 +784,9 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"n = 140_000_000\n",
"@time for i in 1:10\n", "@time for i in 1:10\n",
" @show compute_π(140_000_000)\n", " @show compute_π(n)\n",
"end" "end"
] ]
}, },
@ -810,7 +812,7 @@
" a) 10*t\n", " a) 10*t\n",
" b) t\n", " b) t\n",
" c) 0.1*t\n", " c) 0.1*t\n",
" d) near 0*t \n", " d) O(1) \n",
"\n" "\n"
] ]
}, },
@ -821,8 +823,9 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"n = 140_000_000\n",
"@time for i in 1:10\n", "@time for i in 1:10\n",
" @async @show compute_π(140_000_000)\n", " @async @show compute_π(n)\n",
"end" "end"
] ]
}, },
@ -848,7 +851,7 @@
" a) 10*t\n", " a) 10*t\n",
" b) t\n", " b) t\n",
" c) 0.1*t\n", " c) 0.1*t\n",
" d) near 0*t \n" " d) O(1) \n"
] ]
}, },
{ {
@ -858,8 +861,9 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"n = 140_000_000\n",
"@time @sync for i in 1:10\n", "@time @sync for i in 1:10\n",
" @async @show compute_π(140_000_000)\n", " @async @show compute_π(n)\n",
"end" "end"
] ]
}, },
@ -884,7 +888,7 @@
"\n", "\n",
" a) infinity\n", " a) infinity\n",
" b) 1 second\n", " b) 1 second\n",
" c) near 0 seconds\n", " c) less than 1 seconds\n",
" d) 3 seconds" " d) 3 seconds"
] ]
}, },
@ -934,7 +938,7 @@
"\n", "\n",
" a) infinity\n", " a) infinity\n",
" b) 1 second\n", " b) 1 second\n",
" c) near 0 seconds\n", " c) less than 1 seconds\n",
" d) 3 seconds" " d) 3 seconds"
] ]
}, },