UNPKG

1.45 kBPlain TextView Raw
1A = gallery("fiedler", 25);
2
3iterations = 10000;
4
5# --------------- ADD ---------------------
6timeStart = time();
7for 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;
18endfor
19timeEnd = time();
20duration = timeEnd - timeStart; # seconds
21addDuration = duration / iterations * 1e6 # microseconds
22
23# --------------- MULTIPLY ---------------------
24timeStart = time();
25for 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;
36endfor
37timeEnd = time();
38duration = timeEnd - timeStart; # seconds
39multiplyDuration = duration / iterations * 1e6 # microseconds
40
41# --------------- TRANSPOSE ---------------------
42timeStart = time();
43for 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';
54endfor
55timeEnd = time();
56duration = timeEnd - timeStart; # seconds
57transposeDuration = duration / iterations * 1e6 # microseconds
58
59# --------------- DETERMINANT ---------------------
60timeStart = time();
61for 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);
72endfor
73timeEnd = time();
74duration = timeEnd - timeStart; # seconds
75determinantDuration = duration / iterations * 1e6 # microseconds