definitions.h Source File

CPP API: definitions.h Source File
definitions.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2020-2026 MEmilio
3 *
4 * Authors: Rene Schmieding
5 *
6 * Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20 #ifndef MIO_TIMER_DEFINITIONS_H
21 #define MIO_TIMER_DEFINITIONS_H
22 
23 #include "memilio/utils/mioomp.h"
24 
25 #include <chrono>
26 #include <ctime>
27 
28 namespace mio
29 {
30 namespace timing
31 {
32 
33 #ifdef MEMILIO_ENABLE_OPENMP
34 
35 using TimeType = decltype(omp_get_wtime());
36 using DurationType = decltype(omp_get_wtime());
37 
38 #else
39 
40 using TimeType = std::chrono::steady_clock::time_point;
41 using DurationType = std::chrono::steady_clock::duration;
42 
43 #endif
44 
45 namespace details
46 {
47 
49 inline decltype(auto) convert_to_ticks(DurationType duration)
50 {
51 #ifdef MEMILIO_ENABLE_OPENMP
52  return duration;
53 #else
54  return duration.count();
55 #endif
56 }
57 
58 } // namespace details
59 
65 double time_in_seconds(DurationType duration);
66 
72 
73 } // namespace timing
74 } // namespace mio
75 
76 #endif // MIO_TIMER_DEFINITIONS_H
decltype(auto) convert_to_ticks(DurationType duration)
Convert a duration to integer ticks. Useful for serialization.
Definition: definitions.h:49
std::chrono::steady_clock::time_point TimeType
Definition: definitions.h:40
TimeType get_time_now()
Get the current time.
Definition: definitions.cpp:46
double time_in_seconds(DurationType duration)
Convert a duration to a (floating point) number of seconds.
Definition: definitions.cpp:41
std::chrono::steady_clock::duration DurationType
Definition: definitions.h:41
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30