MFEM  v4.3.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
tic_toc.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2021, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef MFEM_TIC_TOC
13 #define MFEM_TIC_TOC
14 
15 #include "../config/config.hpp"
16 
17 #ifndef MFEM_TIMER_TYPE
18 #ifndef _WIN32
19 #define MFEM_TIMER_TYPE 0
20 #else
21 #define MFEM_TIMER_TYPE 3
22 #endif
23 #endif
24 
25 namespace mfem
26 {
27 
28 namespace internal
29 {
30 class StopWatch;
31 }
32 
33 /// Timing object
34 class StopWatch
35 {
36 private:
37  internal::StopWatch *M;
38 
39 public:
40  StopWatch();
41 
42  /// Clear the elapsed time on the stopwatch and restart it if it's running.
43  void Clear();
44 
45  /// Clear the elapsed time and start the stopwatch.
46  void Start();
47 
48  /// Stop the stopwatch.
49  void Stop();
50 
51  /// Return the time resolution available to the stopwatch.
52  double Resolution();
53 
54  /** Return the number of real seconds elapsed since the stopwatch was
55  started. */
56  double RealTime();
57 
58  /** Return the number of user seconds elapsed since the stopwatch was
59  started. */
60  double UserTime();
61 
62  /** Return the number of system seconds elapsed since the stopwatch was
63  started. */
64  double SystTime();
65  ~StopWatch();
66 };
67 
68 
69 extern StopWatch tic_toc;
70 
71 /// Start the tic_toc timer
72 extern void tic();
73 
74 /// End timing and return the time from tic() to toc() in seconds.
75 extern double toc();
76 
77 }
78 
79 #endif
StopWatch tic_toc
Definition: tic_toc.cpp:447
double RealTime()
Definition: tic_toc.cpp:426
void Stop()
Stop the stopwatch.
Definition: tic_toc.cpp:416
double UserTime()
Definition: tic_toc.cpp:431
Timing object.
Definition: tic_toc.hpp:34
double Resolution()
Return the time resolution available to the stopwatch.
Definition: tic_toc.cpp:421
void Start()
Clear the elapsed time and start the stopwatch.
Definition: tic_toc.cpp:411
void tic()
Start the tic_toc timer.
Definition: tic_toc.cpp:449
double toc()
End timing and return the time from tic() to toc() in seconds.
Definition: tic_toc.cpp:455
void Clear()
Clear the elapsed time on the stopwatch and restart it if it's running.
Definition: tic_toc.cpp:406
double SystTime()
Definition: tic_toc.cpp:436