Home License -- for personal use only. Not for government, academic, research, commercial, or other organizational use. 13-May-2025 19:29:41 wtime_test(): MATLAB/Octave version 9.11.0.2358333 (R2021b) Update 7. Test wtime(). wtime_test01(): Time the RAND function: x = rand ( n, 1 ); Data vectors will be of minimum size 1024 Data vectors will be of maximum size 1048576 Number of repetitions of the operation: 5 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 1024 0.002293 0.000382 0.000020 0.000010 0.000020 2048 0.001891 0.000201 0.000020 0.000020 0.000010 4096 0.000292 0.000040 0.000030 0.000030 0.000030 8192 0.000101 0.000060 0.000060 0.000060 0.000060 16384 0.000342 0.000111 0.000111 0.000111 0.000111 32768 0.000312 0.000211 0.000201 0.000211 0.000201 65536 0.000573 0.000463 0.000412 0.000402 0.000443 131072 0.001127 0.000845 0.000865 0.000825 0.000845 262144 0.002263 0.002203 0.001640 0.001609 0.001670 524288 0.004677 0.004355 0.003319 0.003450 0.003390 1048576 0.009143 0.008620 0.006417 0.006739 0.006769 wtime_test02() Time vectorized operations: y(1:n) = x(1:n) y(1:n) = PI * x(1:n) ) y(1:n) = sqrt ( x(1:n) ) y(1:n) = exp ( x(1:n) ) Data vectors will be of minimum size 4096 Data vectors will be of maximum size 4194304 Number of repetitions of the operation: 5 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000352 0.000020 0.000030 0.000030 0.000030 8192 0.000131 0.000241 0.000030 0.000020 0.000020 16384 0.000080 0.000070 0.000060 0.000060 0.000060 32768 0.000111 0.000121 0.000111 0.000121 0.000111 65536 0.000503 0.000262 0.000221 0.000251 0.000221 131072 0.000322 0.000463 0.000523 0.000463 0.000503 262144 0.000774 0.001026 0.001006 0.001016 0.001076 524288 0.001810 0.002505 0.002092 0.002132 0.002062 1048576 0.006437 0.004325 0.005733 0.004395 0.004416 2097152 0.012181 0.007664 0.009837 0.009857 0.009646 4194304 0.027922 0.016687 0.017180 0.016646 0.016727 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000855 0.000030 0.000030 0.000030 0.000030 8192 0.000101 0.000030 0.000030 0.000030 0.000030 16384 0.000131 0.000121 0.000121 0.000101 0.000091 32768 0.000191 0.000171 0.000171 0.000161 0.000161 65536 0.000644 0.000302 0.000312 0.000312 0.000292 131072 0.000573 0.000563 0.000563 0.000614 0.000563 262144 0.001127 0.001217 0.001137 0.001147 0.001187 524288 0.002354 0.002384 0.002334 0.002344 0.002313 1048576 0.005552 0.006055 0.004818 0.004848 0.004838 2097152 0.011235 0.010893 0.011094 0.010923 0.011205 4194304 0.019302 0.019292 0.019282 0.019171 0.019463 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000352 0.000050 0.000050 0.000050 0.000050 8192 0.000111 0.000091 0.000091 0.000091 0.000101 16384 0.000181 0.000171 0.000191 0.000171 0.000161 32768 0.000312 0.000251 0.000292 0.000241 0.000262 65536 0.000835 0.000422 0.000422 0.000483 0.000433 131072 0.000835 0.000805 0.000855 0.000805 0.000875 262144 0.001821 0.001609 0.001660 0.001640 0.001831 524288 0.003480 0.003269 0.003319 0.003390 0.003601 1048576 0.006478 0.006508 0.006498 0.006498 0.006558 2097152 0.014766 0.015087 0.015128 0.014534 0.015027 4194304 0.026705 0.026725 0.026272 0.027067 0.026212 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000493 0.000080 0.000101 0.000091 0.000091 8192 0.000141 0.000040 0.000050 0.000050 0.000040 16384 0.000191 0.000171 0.000181 0.000161 0.000161 32768 0.000292 0.000302 0.000272 0.000282 0.000262 65536 0.000835 0.000463 0.000473 0.000473 0.000483 131072 0.000905 0.000905 0.000905 0.000915 0.000875 262144 0.001891 0.001720 0.001730 0.001951 0.001720 524288 0.004053 0.003993 0.004033 0.003983 0.003973 1048576 0.007182 0.007202 0.007282 0.007343 0.007272 2097152 0.015188 0.015289 0.015218 0.015309 0.015319 4194304 0.027630 0.027509 0.027751 0.027650 0.027781 wtime_test03 Time unvectorized operations: for i = 1 : n y(i) = x(i) y(i) = PI * x(i) ) y(i) = sqrt ( x(i) ) y(i) = exp ( x(i) ) end Data vectors will be of minimum size 4096 Data vectors will be of maximum size 4194304 Number of repetitions of the operation: 5 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000654 0.000030 0.000030 0.000030 0.000020 8192 0.000231 0.000523 0.000020 0.000020 0.000030 16384 0.000443 0.000412 0.000060 0.000040 0.000040 32768 0.000764 0.000785 0.000070 0.000070 0.000080 65536 0.001720 0.001549 0.000141 0.000181 0.000171 131072 0.002625 0.002937 0.000282 0.000282 0.000292 262144 0.000935 0.000704 0.000664 0.000614 0.000624 524288 0.001227 0.001318 0.001267 0.001227 0.001237 1048576 0.002474 0.002706 0.002474 0.002494 0.002796 2097152 0.004788 0.004798 0.004798 0.004798 0.005019 4194304 0.018035 0.018095 0.018024 0.017994 0.018004 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000533 0.000020 0.000040 0.000020 0.000030 8192 0.000191 0.000020 0.000020 0.000020 0.000020 16384 0.000372 0.000030 0.000030 0.000030 0.000030 32768 0.000724 0.000050 0.000050 0.000060 0.000060 65536 0.001740 0.000121 0.000111 0.000111 0.000111 131072 0.002565 0.000221 0.000262 0.000211 0.000221 262144 0.001408 0.000473 0.000463 0.000463 0.000503 524288 0.000996 0.000966 0.000986 0.000966 0.000996 1048576 0.001800 0.002022 0.001851 0.002022 0.001992 2097152 0.005190 0.003822 0.004053 0.003812 0.003943 4194304 0.007131 0.016496 0.007332 0.015912 0.007131 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000654 0.000040 0.000040 0.000040 0.000040 8192 0.000292 0.000040 0.000050 0.000040 0.000040 16384 0.000553 0.000080 0.000121 0.000111 0.000091 32768 0.000935 0.000201 0.000151 0.000161 0.000151 65536 0.002243 0.000382 0.000312 0.000312 0.000312 131072 0.003551 0.000704 0.000654 0.000654 0.000694 262144 0.001368 0.001509 0.001298 0.001287 0.001287 524288 0.002595 0.003058 0.002645 0.002806 0.002635 1048576 0.005170 0.005512 0.005180 0.005351 0.005170 2097152 0.010280 0.010571 0.010491 0.010189 0.010259 4194304 0.029199 0.029169 0.029199 0.029189 0.029129 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000684 0.000111 0.000111 0.000111 0.000111 8192 0.000211 0.000191 0.000221 0.000191 0.000181 16384 0.000443 0.000372 0.000362 0.000402 0.000402 32768 0.000825 0.000754 0.000754 0.000785 0.000764 65536 0.001941 0.001569 0.001479 0.001479 0.001509 131072 0.003199 0.003078 0.002907 0.002907 0.002947 262144 0.006256 0.006045 0.005894 0.005794 0.005794 524288 0.012020 0.012110 0.011849 0.011808 0.011627 1048576 0.023375 0.023275 0.023245 0.023275 0.023909 2097152 0.047586 0.047998 0.047264 0.047314 0.046550 4194304 0.106085 0.107925 0.106759 0.106537 0.104848 wtime_test04() Time the 2D nearest neighbor problem. Given X(2,N) and Y(2), find X(2,*) closest to Y(2). for i = 1 : n if distance ( x(2,i), y ) < minimum so far x_min = x(2,i) end Data vectors will be of minimum size 1024 Data vectors will be of maximum size 1048576 Number of repetitions of the operation: 5 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 1024 0.001116 0.000010 0.000010 0.000010 0.000020 2048 0.000080 0.000251 0.000010 0.000010 0.000010 4096 0.000111 0.000080 0.000010 0.000020 0.000020 8192 0.000181 0.000151 0.000030 0.000020 0.000030 16384 0.000543 0.000312 0.000070 0.000050 0.000050 32768 0.000674 0.000634 0.000101 0.000091 0.000091 65536 0.001348 0.001257 0.000191 0.000181 0.000181 131072 0.002665 0.002505 0.000392 0.000382 0.000362 262144 0.001036 0.005059 0.000795 0.000764 0.000744 524288 0.001720 0.010078 0.001700 0.001489 0.001489 1048576 0.003349 0.003309 0.003279 0.003098 0.003108 wtime_test05() Time the matrix multiplication problem. Compute C = A * B where A is an L by M matrix, B is an M by N matrix, and so C is an L by N matrix. Minimum value of L = M = N = 4 Maximum value of L = M = N = 1024 Number of repetitions of the operation: 5 Use triple loop for matrix multiplication. Timing results using nested loops: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4 0.002012 0.000201 0.000000 0.000000 0.000010 16 0.000372 0.000312 0.000020 0.000030 0.000020 64 0.005059 0.005140 0.001267 0.001267 0.001318 256 0.119663 0.117461 0.078887 0.078988 0.079450 Use C = A * B matrix multiplication. Timing results using C = A * B: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4 0.000191 0.000262 0.000010 0.000000 0.000010 16 0.143361 0.000010 0.000000 0.000000 0.000000 64 0.000322 0.000030 0.000010 0.000010 0.000010 256 0.000332 0.000221 0.000211 0.000211 0.000211 wtime_test(): Normal end of execution. 13-May-2025 19:29:47