Skip to content

Commit

Permalink
Little update in multiprocessing.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmpedersen committed May 20, 2014
1 parent c3d24be commit 37f6a4e
Showing 1 changed file with 25 additions and 75 deletions.
100 changes: 25 additions & 75 deletions lesson 7/multiprocessing/Multiprocessing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
"outputs": []
},
{
"cell_type": "code",
Expand All @@ -47,21 +46,12 @@
"\n",
"if __name__ == \"__main__\":\n",
" pool = multiprocessing.Pool(processes=4)\n",
" lst = pool.map(pycheck_opt, range(2,int(sys.argv[1])))\n",
" lst = pool.map(pycheck_opt, range(2,int(sys.argv[1]))).get()\n",
" print len([v for v in lst if v])"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Overwriting mp.py\n"
]
}
],
"prompt_number": 6
"outputs": []
},
{
"cell_type": "code",
Expand All @@ -73,8 +63,7 @@
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 7
"outputs": []
},
{
"cell_type": "code",
Expand All @@ -86,24 +75,19 @@
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"168\n",
"168\r\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n"
]
}
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"n = 10000\n",
"%timeit primes(n)\n",
"%timeit run('mp.py %s'%n)"
],
"prompt_number": 12
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
Expand All @@ -115,49 +99,15 @@
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"1 loops, best of 3: 9.54 s per loop\n",
"78498\r\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"78498\r\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"78498\r\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"78498\r\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"1 loops, best of 3: 3.33 s per loop\n"
]
}
],
"prompt_number": 16
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
Expand Down

0 comments on commit 37f6a4e

Please sign in to comment.