Skip to content

Instantly share code, notes, and snippets.

@timholy
Created January 14, 2014 12:35
Show Gist options
  • Save timholy/8417617 to your computer and use it in GitHub Desktop.
Save timholy/8417617 to your computer and use it in GitHub Desktop.
Comparing linear and cartesian indexing for `getindex`
#### getindex ####
Whole array operations:
Small arrays:
1 dimensions (2500000 repeats, 10000000 operations): 1 dimensions (2500000 repeats): elapsed time: 0.550692201 seconds (300220636 bytes allocated)
2 dimensions (625000 repeats, 10000000 operations): 2 dimensions (625000 repeats): elapsed time: 0.178206593 seconds (135331628 bytes allocated)
3 dimensions (156250 repeats, 10000000 operations): 3 dimensions (156250 repeats): elapsed time: 0.099012831 seconds (110292004 bytes allocated)
4 dimensions (39063 repeats, 10000128 operations): 4 dimensions (39063 repeats): elapsed time: 0.074979234 seconds (85292980 bytes allocated)
5 dimensions (9766 repeats, 10000384 operations): 5 dimensions (9766 repeats): elapsed time: 0.064565994 seconds (81701476 bytes allocated)
6 dimensions (2442 repeats, 10002432 operations): 6 dimensions (2442 repeats): elapsed time: 0.063188446 seconds (80623924 bytes allocated)
7 dimensions (611 repeats, 10010624 operations): 7 dimensions (611 repeats): elapsed time: 0.062809535 seconds (80456484 bytes allocated)
8 dimensions (153 repeats, 10027008 operations): 8 dimensions (153 repeats): elapsed time: 0.075186503 seconds (80535940 bytes allocated)
9 dimensions (39 repeats, 10223616 operations): 9 dimensions (39 repeats): elapsed time: 0.070069175 seconds (82094532 bytes allocated)
10 dimensions (10 repeats, 10485760 operations): 10 dimensions (10 repeats): elapsed time: 0.081532541 seconds (84187252 bytes allocated)
Big arrays:
1 dimensions (10 repeats, 10000000 operations): 1 dimensions (10 repeats): elapsed time: 0.043309854 seconds (80000720 bytes allocated)
2 dimensions (10 repeats, 10000000 operations): 2 dimensions (10 repeats): elapsed time: 0.063786104 seconds (80000720 bytes allocated)
3 dimensions (10 repeats, 10000000 operations): 3 dimensions (10 repeats): elapsed time: 0.048274298 seconds (80001120 bytes allocated)
4 dimensions (10 repeats, 10485760 operations): 4 dimensions (10 repeats): elapsed time: 0.051406338 seconds (83887200 bytes allocated)
5 dimensions (10 repeats, 10485760 operations): 5 dimensions (10 repeats): elapsed time: 0.049048044 seconds (83887200 bytes allocated)
6 dimensions (10 repeats, 10000000 operations): 6 dimensions (10 repeats): elapsed time: 0.058784403 seconds (80001120 bytes allocated)
7 dimensions (1 repeats, 10000000 operations): 7 dimensions (1 repeats): elapsed time: 0.064088961 seconds (80000112 bytes allocated)
Slicing with contiguous blocks:
Small arrays:
1 dimensions (2500000 repeats, 10000000 operations): elapsed time: 0.625764791 seconds (299991840 bytes allocated)
2 dimensions (2500000 repeats, 10000000 operations): elapsed time: 0.97220765 seconds (420500120 bytes allocated)
3 dimensions (625000 repeats, 10000000 operations): elapsed time: 1.096706901 seconds (419835400 bytes allocated)
4 dimensions (625000 repeats, 10000000 operations): elapsed time: 1.048247011 seconds (431500132 bytes allocated)
5 dimensions (156250 repeats, 10000000 operations): elapsed time: 0.467072104 seconds (207361056 bytes allocated)
6 dimensions (156250 repeats, 10000000 operations): elapsed time: 0.496604407 seconds (210810456 bytes allocated)
7 dimensions (39063 repeats, 10000128 operations): elapsed time: 0.3508091 seconds (121212592 bytes allocated)
8 dimensions (39063 repeats, 10000128 operations): elapsed time: 2.864820923 seconds (1322590144 bytes allocated)
9 dimensions (9766 repeats, 10000384 operations): elapsed time: 3.00026783 seconds (1377019176 bytes allocated)
10 dimensions (9766 repeats, 10000384 operations): elapsed time: 3.102930591 seconds (1457233652 bytes allocated)
Big arrays:
1 dimensions (10 repeats, 10000000 operations): elapsed time: 0.057108674 seconds (80000720 bytes allocated)
2 dimensions (10000 repeats, 10000000 operations): elapsed time: 0.080812195 seconds (81671840 bytes allocated)
3 dimensions (1000 repeats, 10000000 operations): elapsed time: 0.079267428 seconds (80527840 bytes allocated)
4 dimensions (9766 repeats, 10000384 operations): elapsed time: 0.102572741 seconds (85620128 bytes allocated)
5 dimensions (2442 repeats, 10002432 operations): elapsed time: 0.081005219 seconds (81808608 bytes allocated)
6 dimensions (10000 repeats, 10000000 operations): elapsed time: 0.107741776 seconds (87751840 bytes allocated)
7 dimensions (1000 repeats, 10000000 operations): elapsed time: 0.059218363 seconds (80967840 bytes allocated)
Slicing with non-contiguous blocks:
Small arrays:
1 dimensions (2500000 repeats, 10000000 operations): elapsed time: 0.595990048 seconds (299991840 bytes allocated)
2 dimensions (2500000 repeats, 10000000 operations): elapsed time: 1.30323735 seconds (560348600 bytes allocated)
3 dimensions (625000 repeats, 10000000 operations): elapsed time: 1.134698728 seconds (466131816 bytes allocated)
4 dimensions (625000 repeats, 10000000 operations): elapsed time: 1.288415192 seconds (526372136 bytes allocated)
5 dimensions (156250 repeats, 10000000 operations): elapsed time: 0.551143584 seconds (230399724 bytes allocated)
6 dimensions (156250 repeats, 10000000 operations): elapsed time: 0.626503641 seconds (248126384 bytes allocated)
7 dimensions (39063 repeats, 10000128 operations): elapsed time: 0.411745637 seconds (130485340 bytes allocated)
8 dimensions (39063 repeats, 10000128 operations): elapsed time: 3.072821995 seconds (1339053716 bytes allocated)
9 dimensions (9766 repeats, 10000384 operations): elapsed time: 3.182879246 seconds (1381105400 bytes allocated)
10 dimensions (9766 repeats, 10000384 operations): elapsed time: 4.492579085 seconds (1462836020 bytes allocated)
Big arrays:
1 dimensions (10 repeats, 10000000 operations): elapsed time: 0.065667487 seconds (80000720 bytes allocated)
2 dimensions (10000 repeats, 10000000 operations): elapsed time: 0.135647145 seconds (82231840 bytes allocated)
3 dimensions (1000 repeats, 10000000 operations): elapsed time: 0.155434048 seconds (80607840 bytes allocated)
4 dimensions (9766 repeats, 10000384 operations): elapsed time: 0.739975067 seconds (87104560 bytes allocated)
5 dimensions (2442 repeats, 10002432 operations): elapsed time: 0.667037445 seconds (82218864 bytes allocated)
6 dimensions (10000 repeats, 10000000 operations): elapsed time: 0.224087289 seconds (90311840 bytes allocated)
7 dimensions (1000 repeats, 10000000 operations): elapsed time: 0.262733088 seconds (81215840 bytes allocated)
Random operations:
Small arrays:
1 dimensions (5000000 repeats, 10000000 operations): elapsed time: 1.144372034 seconds (519991840 bytes allocated)
2 dimensions (833334 repeats, 10000008 operations): elapsed time: 0.498504109 seconds (240319004 bytes allocated)
3 dimensions (625000 repeats, 10000000 operations): elapsed time: 1.303293875 seconds (541476796 bytes allocated)
4 dimensions (208334 repeats, 10000032 operations): elapsed time: 0.576858486 seconds (264648720 bytes allocated)
5 dimensions (52084 repeats, 10000128 operations): elapsed time: 0.386109799 seconds (165519956 bytes allocated)
6 dimensions (9766 repeats, 10000384 operations): elapsed time: 0.227663312 seconds (95410808 bytes allocated)
7 dimensions (3256 repeats, 10002432 operations): elapsed time: 0.218237531 seconds (87150988 bytes allocated)
8 dimensions (3256 repeats, 10002432 operations): elapsed time: 2.837050712 seconds (1288738824 bytes allocated)
9 dimensions (1086 repeats, 10008576 operations): elapsed time: 2.996027605 seconds (1366417812 bytes allocated)
10 dimensions (91 repeats, 10063872 operations): elapsed time: 3.12674093 seconds (1452280504 bytes allocated)
Big arrays:
1 dimensions (20 repeats, 10000000 operations): elapsed time: 0.094545382 seconds (80089576 bytes allocated)
2 dimensions (20 repeats, 10000000 operations): elapsed time: 0.087785948 seconds (80003840 bytes allocated)
3 dimensions (25000 repeats, 10000000 operations): elapsed time: 0.234296456 seconds (100512460 bytes allocated)
4 dimensions (39 repeats, 10223616 operations): elapsed time: 0.182654297 seconds (83083400 bytes allocated)
5 dimensions (10 repeats, 10485760 operations): elapsed time: 0.160315527 seconds (85559728 bytes allocated)
6 dimensions (5000 repeats, 10000000 operations): elapsed time: 0.192790492 seconds (88757796 bytes allocated)
7 dimensions (20 repeats, 10000000 operations): elapsed time: 0.193684142 seconds (82070228 bytes allocated)
#### getindex ####
Whole array operations:
Small arrays:
1 dimensions (2500000 repeats, 10000000 operations): 1 dimensions (2500000 repeats): elapsed time: 0.55405778 seconds (300220636 bytes allocated)
2 dimensions (625000 repeats, 10000000 operations): 2 dimensions (625000 repeats): elapsed time: 0.176052129 seconds (135335788 bytes allocated)
3 dimensions (156250 repeats, 10000000 operations): 3 dimensions (156250 repeats): elapsed time: 0.097880269 seconds (110292004 bytes allocated)
4 dimensions (39063 repeats, 10000128 operations): 4 dimensions (39063 repeats): elapsed time: 0.075429984 seconds (85292980 bytes allocated)
5 dimensions (9766 repeats, 10000384 operations): 5 dimensions (9766 repeats): elapsed time: 0.066536612 seconds (81701476 bytes allocated)
6 dimensions (2442 repeats, 10002432 operations): 6 dimensions (2442 repeats): elapsed time: 0.066318262 seconds (80623924 bytes allocated)
7 dimensions (611 repeats, 10010624 operations): 7 dimensions (611 repeats): elapsed time: 0.064619907 seconds (80456484 bytes allocated)
8 dimensions (153 repeats, 10027008 operations): 8 dimensions (153 repeats): elapsed time: 0.077612014 seconds (80535940 bytes allocated)
9 dimensions (39 repeats, 10223616 operations): 9 dimensions (39 repeats): elapsed time: 0.072161902 seconds (82094532 bytes allocated)
10 dimensions (10 repeats, 10485760 operations): 10 dimensions (10 repeats): elapsed time: 0.081799986 seconds (84187252 bytes allocated)
Big arrays:
1 dimensions (10 repeats, 10000000 operations): 1 dimensions (10 repeats): elapsed time: 0.043652452 seconds (80000720 bytes allocated)
2 dimensions (10 repeats, 10000000 operations): 2 dimensions (10 repeats): elapsed time: 0.064005103 seconds (80000720 bytes allocated)
3 dimensions (10 repeats, 10000000 operations): 3 dimensions (10 repeats): elapsed time: 0.04933796 seconds (80001120 bytes allocated)
4 dimensions (10 repeats, 10485760 operations): 4 dimensions (10 repeats): elapsed time: 0.053507796 seconds (83887200 bytes allocated)
5 dimensions (10 repeats, 10485760 operations): 5 dimensions (10 repeats): elapsed time: 0.049289369 seconds (83887200 bytes allocated)
6 dimensions (10 repeats, 10000000 operations): 6 dimensions (10 repeats): elapsed time: 0.05989992 seconds (80001120 bytes allocated)
7 dimensions (1 repeats, 10000000 operations): 7 dimensions (1 repeats): elapsed time: 0.06586569 seconds (80000112 bytes allocated)
Slicing with contiguous blocks:
Small arrays:
1 dimensions (2500000 repeats, 10000000 operations): elapsed time: 0.552941257 seconds (299991840 bytes allocated)
2 dimensions (2500000 repeats, 10000000 operations): elapsed time: 0.962660458 seconds (420585332 bytes allocated)
3 dimensions (625000 repeats, 10000000 operations): elapsed time: 1.104513373 seconds (419985780 bytes allocated)
4 dimensions (625000 repeats, 10000000 operations): elapsed time: 1.046146517 seconds (431841608 bytes allocated)
5 dimensions (156250 repeats, 10000000 operations): elapsed time: 0.455108846 seconds (207631308 bytes allocated)
6 dimensions (156250 repeats, 10000000 operations): elapsed time: 0.461422797 seconds (211128764 bytes allocated)
7 dimensions (39063 repeats, 10000128 operations): elapsed time: 0.319080259 seconds (121893460 bytes allocated)
8 dimensions (39063 repeats, 10000128 operations): elapsed time: 0.321493186 seconds (122989404 bytes allocated)
9 dimensions (9766 repeats, 10000384 operations): elapsed time: 0.259558796 seconds (97449048 bytes allocated)
10 dimensions (9766 repeats, 10000384 operations): elapsed time: 0.248963745 seconds (97721432 bytes allocated)
Big arrays:
1 dimensions (10 repeats, 10000000 operations): elapsed time: 0.054701828 seconds (80000720 bytes allocated)
2 dimensions (10000 repeats, 10000000 operations): elapsed time: 0.09290978 seconds (81671840 bytes allocated)
3 dimensions (1000 repeats, 10000000 operations): elapsed time: 0.077388778 seconds (80527840 bytes allocated)
4 dimensions (9766 repeats, 10000384 operations): elapsed time: 0.088129298 seconds (85620128 bytes allocated)
5 dimensions (2442 repeats, 10002432 operations): elapsed time: 0.080813363 seconds (81808608 bytes allocated)
6 dimensions (10000 repeats, 10000000 operations): elapsed time: 0.093769329 seconds (87751840 bytes allocated)
7 dimensions (1000 repeats, 10000000 operations): elapsed time: 0.059252059 seconds (80967840 bytes allocated)
Slicing with non-contiguous blocks:
Small arrays:
1 dimensions (2500000 repeats, 10000000 operations): elapsed time: 0.608070874 seconds (299991840 bytes allocated)
2 dimensions (2500000 repeats, 10000000 operations): elapsed time: 1.283569802 seconds (560444208 bytes allocated)
3 dimensions (625000 repeats, 10000000 operations): elapsed time: 1.146422622 seconds (466220444 bytes allocated)
4 dimensions (625000 repeats, 10000000 operations): elapsed time: 1.314536606 seconds (526629392 bytes allocated)
5 dimensions (156250 repeats, 10000000 operations): elapsed time: 0.555078191 seconds (230562344 bytes allocated)
6 dimensions (156250 repeats, 10000000 operations): elapsed time: 0.630405286 seconds (248318128 bytes allocated)
7 dimensions (39063 repeats, 10000128 operations): elapsed time: 0.416279985 seconds (131019704 bytes allocated)
8 dimensions (39063 repeats, 10000128 operations): elapsed time: 0.595087477 seconds (139327252 bytes allocated)
9 dimensions (9766 repeats, 10000384 operations): elapsed time: 0.622577303 seconds (101389756 bytes allocated)
10 dimensions (9766 repeats, 10000384 operations): elapsed time: 1.492036793 seconds (103154420 bytes allocated)
Big arrays:
1 dimensions (10 repeats, 10000000 operations): elapsed time: 0.055953614 seconds (80000720 bytes allocated)
2 dimensions (10000 repeats, 10000000 operations): elapsed time: 0.144957797 seconds (82231840 bytes allocated)
3 dimensions (1000 repeats, 10000000 operations): elapsed time: 0.156528123 seconds (80607840 bytes allocated)
4 dimensions (9766 repeats, 10000384 operations): elapsed time: 0.768577628 seconds (87104560 bytes allocated)
5 dimensions (2442 repeats, 10002432 operations): elapsed time: 0.659300928 seconds (82218864 bytes allocated)
6 dimensions (10000 repeats, 10000000 operations): elapsed time: 0.236095203 seconds (90311840 bytes allocated)
7 dimensions (1000 repeats, 10000000 operations): elapsed time: 0.25672553 seconds (81215840 bytes allocated)
Random operations:
Small arrays:
1 dimensions (2500000 repeats, 10000000 operations): elapsed time: 0.605383066 seconds (299991840 bytes allocated)
2 dimensions (1666667 repeats, 10000002 operations): elapsed time: 0.903426544 seconds (400631568 bytes allocated)
3 dimensions (416667 repeats, 10000008 operations): elapsed time: 0.941223213 seconds (387927912 bytes allocated)
4 dimensions (208334 repeats, 10000032 operations): elapsed time: 0.615645152 seconds (270064928 bytes allocated)
5 dimensions (52084 repeats, 10000128 operations): elapsed time: 0.316507596 seconds (162659228 bytes allocated)
6 dimensions (26042 repeats, 10000128 operations): elapsed time: 0.303764805 seconds (117479932 bytes allocated)
7 dimensions (2171 repeats, 10003968 operations): elapsed time: 0.197939051 seconds (85830884 bytes allocated)
8 dimensions (1447 repeats, 10001664 operations): elapsed time: 0.237714801 seconds (85306292 bytes allocated)
9 dimensions (272 repeats, 10027008 operations): elapsed time: 0.253812479 seconds (83870552 bytes allocated)
10 dimensions (2171 repeats, 10003968 operations): elapsed time: 0.250555933 seconds (88723812 bytes allocated)
Big arrays:
1 dimensions (10 repeats, 10000000 operations): elapsed time: 0.070044509 seconds (80088856 bytes allocated)
2 dimensions (14 repeats, 10500000 operations): elapsed time: 0.086704062 seconds (84429532 bytes allocated)
3 dimensions (1000 repeats, 10000000 operations): elapsed time: 0.147769267 seconds (81995340 bytes allocated)
4 dimensions (3256 repeats, 10002432 operations): elapsed time: 0.15678721 seconds (84546568 bytes allocated)
5 dimensions (1221 repeats, 10002432 operations): elapsed time: 0.192745919 seconds (82989144 bytes allocated)
6 dimensions (125 repeats, 10000000 operations): elapsed time: 0.160506203 seconds (81606860 bytes allocated)
7 dimensions (125 repeats, 10000000 operations): elapsed time: 0.208833288 seconds (82770072 bytes allocated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment