|
107 | 107 | "name": "stdout",
|
108 | 108 | "output_type": "stream",
|
109 | 109 | "text": [
|
110 |
| - "CPU times: user 11.2 s, sys: 173 ms, total: 11.3 s\n", |
111 |
| - "Wall time: 11.5 s\n" |
| 110 | + "CPU times: user 11.7 s, sys: 323 ms, total: 12 s\n", |
| 111 | + "Wall time: 12.2 s\n" |
112 | 112 | ]
|
113 | 113 | }
|
114 | 114 | ],
|
|
142 | 142 | "name": "stdout",
|
143 | 143 | "output_type": "stream",
|
144 | 144 | "text": [
|
145 |
| - "2.09 s ± 21.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" |
| 145 | + "2.14 s ± 13.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" |
146 | 146 | ]
|
147 | 147 | }
|
148 | 148 | ],
|
|
195 | 195 | "name": "stdout",
|
196 | 196 | "output_type": "stream",
|
197 | 197 | "text": [
|
198 |
| - "6.14 s ± 98.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" |
| 198 | + "6.22 s ± 89.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" |
199 | 199 | ]
|
200 | 200 | }
|
201 | 201 | ],
|
|
248 | 248 | "name": "stdout",
|
249 | 249 | "output_type": "stream",
|
250 | 250 | "text": [
|
251 |
| - "12.2 s ± 439 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" |
| 251 | + "12.1 s ± 289 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" |
252 | 252 | ]
|
253 | 253 | }
|
254 | 254 | ],
|
|
347 | 347 | "name": "stdout",
|
348 | 348 | "output_type": "stream",
|
349 | 349 | "text": [
|
350 |
| - "CPU times: user 0 ns, sys: 36.6 ms, total: 36.6 ms\n", |
351 |
| - "Wall time: 36.4 ms\n" |
| 350 | + "CPU times: user 8.4 ms, sys: 110 ms, total: 118 ms\n", |
| 351 | + "Wall time: 119 ms\n" |
352 | 352 | ]
|
353 | 353 | }
|
354 | 354 | ],
|
355 | 355 | "source": [
|
356 | 356 | "%time np.save(bin_file_name, data)"
|
357 | 357 | ]
|
358 | 358 | },
|
| 359 | + { |
| 360 | + "cell_type": "markdown", |
| 361 | + "id": "3742048e-11ec-4ea0-80c6-acce043c3ffc", |
| 362 | + "metadata": {}, |
| 363 | + "source": [ |
| 364 | + "### `np.load`" |
| 365 | + ] |
| 366 | + }, |
359 | 367 | {
|
360 | 368 | "cell_type": "code",
|
361 | 369 | "execution_count": 14,
|
|
366 | 374 | "name": "stdout",
|
367 | 375 | "output_type": "stream",
|
368 | 376 | "text": [
|
369 |
| - "17.6 ms ± 922 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n" |
| 377 | + "19.3 ms ± 2.65 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n" |
370 | 378 | ]
|
371 | 379 | }
|
372 | 380 | ],
|
|
401 | 409 | "print(loaded_data.shape, loaded_data.dtype)"
|
402 | 410 | ]
|
403 | 411 | },
|
| 412 | + { |
| 413 | + "cell_type": "markdown", |
| 414 | + "id": "98a9f5f1-fb81-4c18-9631-e82df696e033", |
| 415 | + "metadata": {}, |
| 416 | + "source": [ |
| 417 | + "### `np.fromfile`" |
| 418 | + ] |
| 419 | + }, |
| 420 | + { |
| 421 | + "cell_type": "code", |
| 422 | + "execution_count": 16, |
| 423 | + "id": "5eec68f1-6fcd-4ea6-9cfa-e8b838dc4735", |
| 424 | + "metadata": {}, |
| 425 | + "outputs": [ |
| 426 | + { |
| 427 | + "name": "stdout", |
| 428 | + "output_type": "stream", |
| 429 | + "text": [ |
| 430 | + "16.7 ms ± 1.3 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)\n" |
| 431 | + ] |
| 432 | + } |
| 433 | + ], |
| 434 | + "source": [ |
| 435 | + "%timeit np.fromfile(bin_file_name)" |
| 436 | + ] |
| 437 | + }, |
| 438 | + { |
| 439 | + "cell_type": "markdown", |
| 440 | + "id": "3e43e113-295c-4e68-880c-a789ff0b7d6b", |
| 441 | + "metadata": {}, |
| 442 | + "source": [ |
| 443 | + "Verifying the loaded data is always wise." |
| 444 | + ] |
| 445 | + }, |
| 446 | + { |
| 447 | + "cell_type": "code", |
| 448 | + "execution_count": 17, |
| 449 | + "id": "fb5267ba-6e37-45c7-b2e5-b64476c5c564", |
| 450 | + "metadata": {}, |
| 451 | + "outputs": [ |
| 452 | + { |
| 453 | + "name": "stdout", |
| 454 | + "output_type": "stream", |
| 455 | + "text": [ |
| 456 | + "(10000016,) float64\n" |
| 457 | + ] |
| 458 | + } |
| 459 | + ], |
| 460 | + "source": [ |
| 461 | + "loaded_data = np.fromfile(bin_file_name)\n", |
| 462 | + "print(loaded_data.shape, loaded_data.dtype)" |
| 463 | + ] |
| 464 | + }, |
404 | 465 | {
|
405 | 466 | "cell_type": "markdown",
|
406 | 467 | "id": "13c58d18-7eac-4146-9e35-042db70db30e",
|
|
419 | 480 | },
|
420 | 481 | {
|
421 | 482 | "cell_type": "code",
|
422 |
| - "execution_count": 16, |
| 483 | + "execution_count": 18, |
423 | 484 | "id": "d1ce08c0-f7f6-4f4c-9b8f-058b19ebb20b",
|
424 | 485 | "metadata": {},
|
425 | 486 | "outputs": [],
|
|
445 | 506 | },
|
446 | 507 | {
|
447 | 508 | "cell_type": "code",
|
448 |
| - "execution_count": 17, |
| 509 | + "execution_count": 19, |
449 | 510 | "id": "50999bbc-a99c-4c6b-bdc8-275c4a35670e",
|
450 | 511 | "metadata": {},
|
451 | 512 | "outputs": [],
|
|
455 | 516 | },
|
456 | 517 | {
|
457 | 518 | "cell_type": "code",
|
458 |
| - "execution_count": 18, |
| 519 | + "execution_count": 20, |
459 | 520 | "id": "fa7576a2-d24b-4225-92ed-ceff98f58dbe",
|
460 | 521 | "metadata": {},
|
461 | 522 | "outputs": [
|
462 | 523 | {
|
463 | 524 | "name": "stdout",
|
464 | 525 | "output_type": "stream",
|
465 | 526 | "text": [
|
466 |
| - "CPU times: user 5.57 ms, sys: 29.4 ms, total: 35 ms\n", |
467 |
| - "Wall time: 34.4 ms\n" |
| 527 | + "CPU times: user 24 ms, sys: 69.1 ms, total: 93.1 ms\n", |
| 528 | + "Wall time: 94.4 ms\n" |
468 | 529 | ]
|
469 | 530 | }
|
470 | 531 | ],
|
|
477 | 538 | },
|
478 | 539 | {
|
479 | 540 | "cell_type": "code",
|
480 |
| - "execution_count": 19, |
| 541 | + "execution_count": 21, |
481 | 542 | "id": "ef30122b-d2a6-4ece-a56e-5f8979bd1ee2",
|
482 | 543 | "metadata": {},
|
483 | 544 | "outputs": [
|
484 | 545 | {
|
485 | 546 | "name": "stdout",
|
486 | 547 | "output_type": "stream",
|
487 | 548 | "text": [
|
488 |
| - "32 ms ± 3.04 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n" |
| 549 | + "26.9 ms ± 308 μs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n" |
489 | 550 | ]
|
490 | 551 | }
|
491 | 552 | ],
|
|
514 | 575 | },
|
515 | 576 | {
|
516 | 577 | "cell_type": "code",
|
517 |
| - "execution_count": 20, |
| 578 | + "execution_count": 22, |
518 | 579 | "id": "78a90431-3976-4bb0-811f-40a49307ea0a",
|
519 | 580 | "metadata": {},
|
520 | 581 | "outputs": [
|
|
551 | 612 | },
|
552 | 613 | {
|
553 | 614 | "cell_type": "code",
|
554 |
| - "execution_count": 21, |
| 615 | + "execution_count": 23, |
555 | 616 | "id": "5d6b4dce-7937-4f9f-a4c9-8d74c8d117e1",
|
556 | 617 | "metadata": {},
|
557 | 618 | "outputs": [],
|
|
0 commit comments