1 // SPDX-License-Identifier: Apache-2.0
2 //
3 // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
4 // Copyright 2008-2016 National ICT Australia (NICTA)
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 // ------------------------------------------------------------------------
17 
18 
19 //! \addtogroup wall_clock
20 //! @{
21 
22 
23 inline
wall_clock()24 wall_clock::wall_clock()
25   {
26   arma_extra_debug_sigprint();
27   }
28 
29 
30 
31 inline
~wall_clock()32 wall_clock::~wall_clock()
33   {
34   arma_extra_debug_sigprint();
35   }
36 
37 
38 
39 inline
40 void
tic()41 wall_clock::tic()
42   {
43   arma_extra_debug_sigprint();
44 
45   chrono_time1 = std::chrono::steady_clock::now();
46   valid = true;
47   }
48 
49 
50 
51 inline
52 double
toc()53 wall_clock::toc()
54   {
55   arma_extra_debug_sigprint();
56 
57   if(valid)
58     {
59     const std::chrono::steady_clock::time_point chrono_time2 = std::chrono::steady_clock::now();
60 
61     typedef std::chrono::duration<double> duration_type;  // TODO: check this
62 
63     const duration_type chrono_span = std::chrono::duration_cast< duration_type >(chrono_time2 - chrono_time1);
64 
65     return chrono_span.count();
66     }
67 
68   return 0.0;
69   }
70 
71 
72 //! @}
73