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 %> \warning
42 %> This is an internal ``protected`` class attribute
43 %> that is inaccessible to the end users.<br>
44 %>
45 clock = 0;
46 end
47
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49
50 properties(Hidden)
51 %>
52 %> ``start``
53 %>
54 %> The scalar MATLAB real containing the timer start.<br>
55 %>
56 %> \warning
57 %> This is an internal ``Hidden`` class attribute
58 %> that is inaccessible to the end users.<br>
59 %>
60 start;
61 end
62
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 methods(Access = public)
66
67 %> \brief
68 %> Return a scalar object of class [pm.timing.Timer](@ref Timer).<br>
69 %>
70 %> \details
71 %> This is the constructor of the class [pm.timing.Timer](@ref Timer).<br>
72 %>
73 %> \return
74 %> ``self`` : The output scalar object of class [pm.timing.Timer](@ref Timer).<br>
75 %>
76 %> \interface{Timer}
77 %> \code{.m}
78 %>
79 %> self = pm.timing.Timer()
80 %>
81 %> \endcode
82 %>
83 %> \example{Timer}
84 %> \include{lineno} example/timing/Timer/main.m
85 %> \output{Timer}
86 %> \include{lineno} example/timing/Timer/main.out.m
87 %>
88 %> \final{Timer}
89 %>
90 %> \author
91 %> \JoshuaOsborne, May 21 2024, 5:49 AM, University of Texas at Arlington<br>
92 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
93 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
94 function self = Timer()
95 self.tic();
96 end
97
98 %> \brief
99 %> Reset the timer, equivalent to reconstructing the timer object.<br>
100 %> This is a dynamic method of the class [pm.timing.Timer](@ref Timer).
101 %>
102 %> \interface{tic}
103 %> \code{.m}
104 %>
105 %> timer = pm.timing.Timer()
106 %> timer.tic()
107 %>
108 %> \endcode
109 %>
110 %> \final{tic}
111 %>
112 %> \author
113 %> \JoshuaOsborne, May 21 2024, 5:50 AM, University of Texas at Arlington<br>
114 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
115 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
116 function tic(self)
117 self.start = tic();
118 self.clock = 0;
119 end
120
121 %> \brief
122 %> Return a scalar MATLAB ``real`` containing the time
123 %> past since the (re)construction of the timer object.<br>
124 %>
125 %> \details
126 %> Also, set the ``clock`` attribute of the parent object.<br>
127 %> This is a dynamic method of the class [pm.timing.Timer](@ref Timer).<br>
128 %>
129 %> \return
130 %> ``clock`` : The output scalar MATLAB ``real`` containing the time
131 %> past since the (re)construction of the timer object.<br>
132 %>
133 %> \interface{toc}
134 %> \code{.m}
135 %>
136 %> timer = pm.timing.Timer()
137 %> clock = timer.toc()
138 %>
139 %> \endcode
140 %>
141 %> \final{toc}
142 %>
143 %> \author
144 %> \JoshuaOsborne, May 21 2024, 5:58 AM, University of Texas at Arlington<br>
145 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
146 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
147 function clock = toc(self)
148 self.clock = toc(self.start);
149 clock = self.clock;
150 end
151
152 %> \brief
153 %> Return a scalar MATLAB ``real`` containing the time past
154 %> since the last time measurement by the timer object.<br>
155 %> Also, set the ``clock`` attribute of the parent object.<br>
156 %> This is a dynamic method of the class [pm.timing.Timer](@ref Timer).<br>
157 %>
158 %> \return
159 %> ``delta`` : The output scalar MATLAB ``real`` containing the time
160 %> past since the last time measurement by the timer object.<br>
161 %>
162 %> \interface{del}
163 %> \code{.m}
164 %>
165 %> timer = pm.timing.Timer()
166 %> delta = timer.del()
167 %> \endcode
168 %>
169 %> \final{del}
170 %>
171 %> \author
172 %> \JoshuaOsborne, May 21 2024, 5:59 AM, University of Texas at Arlington<br>
173 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
174 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
175 function delta = del(self)
176 delta = self.clock;
177 delta = self.toc() - delta;
178 end
179
180 end
181
182end
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:48
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:64
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...