simplify puzzle notebook
This commit is contained in:
parent
0896683560
commit
3db360b13b
21
puzzle.ipynb
21
puzzle.ipynb
|
@ -32,10 +32,8 @@
|
|||
"# create a collection of time series\n",
|
||||
"# in real life, this data comes from an experiment/simulation\n",
|
||||
"n_series = 128\n",
|
||||
"len_one_series = 2**15 # ➔ 2^15 = 32768 items (8 B x 2^15 = 262144 B = 256 K)\n",
|
||||
"time_series = []\n",
|
||||
"for idx in range(n_series):\n",
|
||||
" time_series.append(np.zeros((len_one_series,1), dtype='float64'))"
|
||||
"len_one_series = 2**20 # ➔ 2^20 = 1,048,576 items (8 B x 2^20 = 8,388,608 B = 8 M)\n",
|
||||
"time_series = np.zeros((n_series, len_one_series), dtype='float64')"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -52,9 +50,10 @@
|
|||
"outputs": [],
|
||||
"source": [
|
||||
"# how much memory does one time series need?\n",
|
||||
"ts_size = time_series[0].nbytes/2**10 # -> 2^10 is 1 K\n",
|
||||
"print(f'Size of one time series: {int(ts_size)} K')\n",
|
||||
"print(f'Size of collection: {int(n_series*ts_size/1024)} M')"
|
||||
"ts_size = time_series[0].nbytes/2**20 # -> 2^20 is 1 M\n",
|
||||
"total_size = time_series.nbytes/2**20\n",
|
||||
"print(f'Size of one time series: {int(ts_size)} M')\n",
|
||||
"print(f'Size of collection: {int(total_size)} M')"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -112,7 +111,7 @@
|
|||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x = np.zeros((n_series, len_one_series, 1), dtype='float64')\n",
|
||||
"x = np.zeros((n_series, len_one_series), dtype='float64')\n",
|
||||
"%timeit load_data_row(x, time_series)"
|
||||
]
|
||||
},
|
||||
|
@ -129,7 +128,7 @@
|
|||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x = np.zeros((len_one_series, n_series, 1), dtype='float64')\n",
|
||||
"x = np.zeros((len_one_series, n_series), dtype='float64')\n",
|
||||
"%timeit load_data_column(x, time_series)"
|
||||
]
|
||||
},
|
||||
|
@ -139,7 +138,7 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# on my machine: 2.2 ms vs 33.9 ms ≈ 15x slowdown!!!"
|
||||
"# on my machine: 31 ms vs 1240 ms ≈ 40x slowdown!!!"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -159,7 +158,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.4"
|
||||
"version": "3.12.5"
|
||||
},
|
||||
"nteract": {
|
||||
"version": "0.28.0"
|
||||
|
|
Loading…
Reference in a new issue