1 | A = gallery("fiedler", 25);
|
2 |
|
3 | iterations = 10000;
|
4 |
|
5 | # --------------- ADD ---------------------
|
6 | timeStart = time();
|
7 | for n = 1:(iterations/10)
|
8 | B = A + A;
|
9 | B = A + A;
|
10 | B = A + A;
|
11 | B = A + A;
|
12 | B = A + A;
|
13 | B = A + A;
|
14 | B = A + A;
|
15 | B = A + A;
|
16 | B = A + A;
|
17 | B = A + A;
|
18 | endfor
|
19 | timeEnd = time();
|
20 | duration = timeEnd - timeStart; # seconds
|
21 | addDuration = duration / iterations * 1e6 # microseconds
|
22 |
|
23 | # --------------- MULTIPLY ---------------------
|
24 | timeStart = time();
|
25 | for n = 1:(iterations/10)
|
26 | B = A * A;
|
27 | B = A * A;
|
28 | B = A * A;
|
29 | B = A * A;
|
30 | B = A * A;
|
31 | B = A * A;
|
32 | B = A * A;
|
33 | B = A * A;
|
34 | B = A * A;
|
35 | B = A * A;
|
36 | endfor
|
37 | timeEnd = time();
|
38 | duration = timeEnd - timeStart; # seconds
|
39 | multiplyDuration = duration / iterations * 1e6 # microseconds
|
40 |
|
41 | # --------------- TRANSPOSE ---------------------
|
42 | timeStart = time();
|
43 | for n = 1:(iterations/10)
|
44 | B = A';
|
45 | B = A';
|
46 | B = A';
|
47 | B = A';
|
48 | B = A';
|
49 | B = A';
|
50 | B = A';
|
51 | B = A';
|
52 | B = A';
|
53 | B = A';
|
54 | endfor
|
55 | timeEnd = time();
|
56 | duration = timeEnd - timeStart; # seconds
|
57 | transposeDuration = duration / iterations * 1e6 # microseconds
|
58 |
|
59 | # --------------- DETERMINANT ---------------------
|
60 | timeStart = time();
|
61 | for n = 1:(iterations/10)
|
62 | B = det(A);
|
63 | B = det(A);
|
64 | B = det(A);
|
65 | B = det(A);
|
66 | B = det(A);
|
67 | B = det(A);
|
68 | B = det(A);
|
69 | B = det(A);
|
70 | B = det(A);
|
71 | B = det(A);
|
72 | endfor
|
73 | timeEnd = time();
|
74 | duration = timeEnd - timeStart; # seconds
|
75 | determinantDuration = duration / iterations * 1e6 # microseconds
|