MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
tic_toc.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, 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#include <memory>
17
18#ifndef MFEM_TIMER_TYPE
19#ifndef _WIN32
20#define MFEM_TIMER_TYPE 0
21#else
22#define MFEM_TIMER_TYPE 3
23#endif
24#endif
25
26namespace mfem
27{
28
29namespace internal
30{
31class StopWatch;
32}
33
34/// Timing object
36{
37private:
38 std::unique_ptr<internal::StopWatch> M; ///< Pointer to implementation.
39
40public:
41 /// Creates a new (stopped) StopWatch object.
42 StopWatch();
43 StopWatch(const StopWatch &);
44
45 /// Clear the elapsed time on the stopwatch and restart it if it's running.
46 void Clear();
47
48 /// Start the stopwatch. The elapsed time is @b not cleared.
49 void Start();
50
51 /// Stop the stopwatch.
52 void Stop();
53
54 /// @brief Clears and restarts the stopwatch. Equivalent to Clear() followed by
55 /// Start().
56 void Restart();
57
58 /// Return the time resolution available to the stopwatch.
59 double Resolution();
60
61 /// @brief Return the number of real seconds elapsed since the stopwatch was
62 /// started.
63 double RealTime();
64
65 /// @brief Return the number of user seconds elapsed since the stopwatch was
66 /// started.
67 double UserTime();
68
69 /// @brief Return the number of system seconds elapsed since the stopwatch
70 /// was started.
71 double SystTime();
72
73 /// Default destructor.
75};
76
77
78extern MFEM_EXPORT StopWatch tic_toc;
79
80/// Start the tic_toc timer
81extern void tic();
82
83/// End timing and return the time from tic() to toc() in seconds.
84extern double toc();
85
86}
87
88#endif
Timing object.
Definition tic_toc.hpp:36
double SystTime()
Return the number of system seconds elapsed since the stopwatch was started.
Definition tic_toc.cpp:442
double RealTime()
Return the number of real seconds elapsed since the stopwatch was started.
Definition tic_toc.cpp:432
~StopWatch()
Default destructor.
void Start()
Start the stopwatch. The elapsed time is not cleared.
Definition tic_toc.cpp:411
void Restart()
Clears and restarts the stopwatch. Equivalent to Clear() followed by Start().
Definition tic_toc.cpp:416
StopWatch()
Creates a new (stopped) StopWatch object.
Definition tic_toc.cpp:401
double UserTime()
Return the number of user seconds elapsed since the stopwatch was started.
Definition tic_toc.cpp:437
double Resolution()
Return the time resolution available to the stopwatch.
Definition tic_toc.cpp:427
void Stop()
Stop the stopwatch.
Definition tic_toc.cpp:422
void Clear()
Clear the elapsed time on the stopwatch and restart it if it's running.
Definition tic_toc.cpp:406
double toc()
End timing and return the time from tic() to toc() in seconds.
Definition tic_toc.cpp:458
void tic()
Start the tic_toc timer.
Definition tic_toc.cpp:452
StopWatch tic_toc
Definition tic_toc.cpp:450