ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
Timer.m
Go to the documentation of this file.
1%> \brief
2%> This is the base class for generating objects
3%> that can time interval consecutively.<br>
4%>
5%> \details
6%> The main utility of this timer class
7%> is its dynamic ``del()`` method which
8%> can compute the time elapsed since the
9%> last measurement in one function call.
10%>
11%> \devnote
12%> The ``handle`` superclass is essential to allow
13%> object modification by the object methods.<br>
14%>
15%> \note
16%> See the documentation of the class constructor.<br>
17%>
18%> \note
19%> See below for information on the attributes (properties).<br>
20%>
21%> \note
22%> See below for information on the methods.<br>
23%>
24%> \final
25%>
26%> \author
27%> \JoshuaOsborne, May 21 2024, 5:47 AM, University of Texas at Arlington<br>
28%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
29%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
30classdef Timer < pm.matlab.Handle
31
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33
34 properties(Access = protected)
35 %>
36 %> ``clock``
37 %>
38 %> The scalar MATLAB real containing the most recent
39 %> timing since the construction of the timer.<br>
40 %>
41 clock = 0;
42 end
43
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45
46 properties(Hidden)
47 %>
48 %> ``start``
49 %>
50 %> The scalar MATLAB real containing the timer start.<br>
51 %>
52 start;
53 end
54
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 methods(Access = public)
58
59 %> \brief
60 %> Return a scalar object of class [pm.timing.Timer](@ref Timer).<br>
61 %>
62 %> \details
63 %> This is the constructor of the class [pm.timing.Timer](@ref Timer).<br>
64 %>
65 %> \return
66 %> ``self`` : The output scalar object of class [pm.timing.Timer](@ref Timer).<br>
67 %>
68 %> \interface{Timer}
69 %> \code{.m}
70 %>
71 %> self = pm.timing.Timer()
72 %>
73 %> \endcode
74 %>
75 %> \example{Timer}
76 %> \include{lineno} example/timing/Timer/main.m
77 %> \output{Timer}
78 %> \include{lineno} example/timing/Timer/main.out.m
79 %>
80 %> \final{Timer}
81 %>
82 %> \author
83 %> \JoshuaOsborne, May 21 2024, 5:49 AM, University of Texas at Arlington<br>
84 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
85 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
86 function self = Timer()
87 self.tic();
88 end
89
90 %> \brief
91 %> Reset the timer, equivalent to reconstructing the timer object.<br>
92 %> This is a dynamic method of the class [pm.timing.Timer](@ref Timer).
93 %>
94 %> \interface{tic}
95 %> \code{.m}
96 %>
97 %> timer = pm.timing.Timer()
98 %> timer.tic()
99 %>
100 %> \endcode
101 %>
102 %> \final{tic}
103 %>
104 %> \author
105 %> \JoshuaOsborne, May 21 2024, 5:50 AM, University of Texas at Arlington<br>
106 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
107 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
108 function tic(self)
109 self.start = tic();
110 self.clock = 0;
111 end
112
113 %> \brief
114 %> Return a scalar MATLAB ``real`` containing the time
115 %> past since the (re)construction of the timer object.<br>
116 %>
117 %> \details
118 %> Also, set the ``clock`` attribute of the parent object.<br>
119 %> This is a dynamic method of the class [pm.timing.Timer](@ref Timer).<br>
120 %>
121 %> \return
122 %> ``clock`` : The output scalar MATLAB ``real`` containing the time
123 %> past since the (re)construction of the timer object.<br>
124 %>
125 %> \interface{toc}
126 %> \code{.m}
127 %>
128 %> timer = pm.timing.Timer()
129 %> clock = timer.toc()
130 %>
131 %> \endcode
132 %>
133 %> \final{toc}
134 %>
135 %> \author
136 %> \JoshuaOsborne, May 21 2024, 5:58 AM, University of Texas at Arlington<br>
137 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
138 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
139 function clock = toc(self)
140 self.clock = toc(self.start);
141 clock = self.clock;
142 end
143
144 %> \brief
145 %> Return a scalar MATLAB ``real`` containing the time past
146 %> since the last time measurement by the timer object.<br>
147 %> Also, set the ``clock`` attribute of the parent object.<br>
148 %> This is a dynamic method of the class [pm.timing.Timer](@ref Timer).<br>
149 %>
150 %> \return
151 %> ``delta`` : The output scalar MATLAB ``real`` containing the time
152 %> past since the last time measurement by the timer object.<br>
153 %>
154 %> \interface{del}
155 %> \code{.m}
156 %>
157 %> timer = pm.timing.Timer()
158 %> delta = timer.del()
159 %> \endcode
160 %>
161 %> \final{del}
162 %>
163 %> \author
164 %> \JoshuaOsborne, May 21 2024, 5:59 AM, University of Texas at Arlington<br>
165 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
166 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
167 function delta = del(self)
168 delta = self.clock;
169 delta = self.toc() - delta;
170 end
171
172 end
173
174end
This is the base class for generating subclass of MATLAB handle superclass whose annoying methods are...
Definition: Handle.m:24
This is the base class for generating objects that can time interval consecutively.
Definition: Timer.m:31
function tic(in self)
Reset the timer, equivalent to reconstructing the timer object. This is a dynamic method of the clas...
Property clock
Definition: Timer.m:44
function toc(in self)
Return a scalar MATLAB real containing the time past since the (re)construction of the timer object.
function del(in self)
Return a scalar MATLAB real containing the time past since the last time measurement by the timer obj...
function Timer()
Return a scalar object of class pm.timing.Timer.
Property start
Definition: Timer.m:56
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...