Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 44
Functions: 0.0% 0 / 0 / 12
Branches: 0.0% 0 / 0 / 28

OMCompiler/SimulationRuntime/cpp/Core/Utils/extension/measure_time_statistic.cpp
Line Branch Exec Source
1 /*
2 * This file belongs to the OpenModelica Run-Time System
3 *
4 * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), c/o Linköpings
5 * universitet, Department of Computer and Information Science, SE-58183 Linköping, Sweden. All rights
6 * reserved.
7 *
8 * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE
9 * AGPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. ANY
10 * USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
11 * ACCEPTANCE OF THE BSD NEW LICENSE OR THE OSMC PUBLIC LICENSE OR THE AGPL
12 * VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
13 *
14 * The OpenModelica software and the OSMC (Open Source Modelica Consortium) Public License
15 * (OSMC-PL) are obtained from OSMC, either from the above address, from the URLs:
16 * http://www.openmodelica.org or https://github.com/OpenModelica/ or
17 * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica distribution. GNU
18 * AGPL version 3 is obtained from: https://www.gnu.org/licenses/licenses.html#GPL. The BSD NEW
19 * License is obtained from: http://www.opensource.org/licenses/BSD-3-Clause.
20 *
21 * This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY
23 * SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF
24 * OSMC-PL.
25 *
26 */
27
28 #include <Core/ModelicaDefine.h>
29 #include <Core/Modelica.h>
30 #include <Core/Utils/extension/measure_time_statistic.hpp>
31 #include <limits>
32 #include <cmath>
33 #include <algorithm>
34
35 ✗ MeasureTimeValuesStatistic::MeasureTimeValuesStatistic(unsigned long long time) : MeasureTimeValuesRDTSC(time), _quadSum(time),
36 ✗ _minTime(std::numeric_limits<unsigned long long>::max()), _count(10), _killTime(0) {}
37
38 ✗ MeasureTimeValuesStatistic::MeasureTimeValuesStatistic(const MeasureTimeValuesStatistic &timeValues) : MeasureTimeValuesRDTSC(timeValues), _quadSum(timeValues._quadSum), _minTime(timeValues._minTime), _count(timeValues._count), _killTime(timeValues._killTime) {}
39
40 ✗ MeasureTimeValuesStatistic::~MeasureTimeValuesStatistic() {}
41
42
43 ✗ std::string MeasureTimeValuesStatistic::serializeToJson() const
44 {
45 ✗ unsigned long long act_time = (_count < _numCalcs ? _time - _killTime : _time);
46 ✗ unsigned actNumCalcs = (_count < _numCalcs ? _numCalcs-_count : _numCalcs);
47 ✗ long double average = (long double)act_time/actNumCalcs, stdDev = sqrt(((long double)_quadSum/actNumCalcs) -(average*average));// V(x) = E(x*x) - E(x)*E(x)
48 ✗ std::stringstream ss;
49
50 ✗ ss << "\"ncall\":" << _numCalcs << "," << "\"time\":" << _time << ",\"maxTime\":" << _maxTime << ",\"minTime\":" << (_numCalcs == 0 ? 0 : _minTime) << ",\"meanTime\":" << (_numCalcs == 0 ? 0 : average)
51 ✗ << ",\"std.deviation\":" << (_numCalcs == 0 ? 0 : stdDev ) << ",\"std.rel.deviation\":" << (_numCalcs == 0 ? 0 : stdDev/average);
52 ✗ return ss.str();
53 ✗ }
54
55 ✗ void MeasureTimeValuesStatistic::add(MeasureTimeValues *values)
56 {
57 ✗ MeasureTimeValuesRDTSC::add(values);
58
59 MeasureTimeValuesStatistic *val = static_cast<MeasureTimeValuesStatistic*>(values);
60 ✗ if( val->_time < _minTime )
61 ✗ _minTime = val->_time;
62
63 ✗ if(_numCalcs<_count)
64 {
65 ✗ _killTime +=val->_time;
66 }
67 else
68 ✗ _quadSum += val->_time*val->_time;
69 ✗ }
70
71 ✗ void MeasureTimeValuesStatistic::filter(unsigned long long val)
72 {
73
74 ✗ }
75
76 ✗ void MeasureTimeValuesStatistic::sub(MeasureTimeValues *values)
77 {
78 ✗ MeasureTimeValuesRDTSC::sub(values);
79 MeasureTimeValuesStatistic *val = static_cast<MeasureTimeValuesStatistic*>(values);
80 ✗ if(_quadSum > val->_time*val->_time)
81 ✗ _quadSum -= val->_time * val->_time;
82 else
83 ✗ _quadSum = 0ull;
84 ✗ }
85
86 ✗ MeasureTimeValuesStatistic* MeasureTimeValuesStatistic::clone() const
87 {
88 ✗ return new MeasureTimeValuesStatistic(*this);
89 }
90
91 ✗ void MeasureTimeValuesStatistic::reset()
92 {
93 ✗ MeasureTimeValues::reset();
94 ✗ _quadSum = 0;
95 ✗ _count = 0;
96 ✗ _minTime = 0;
97 ✗ _killTime = 0;
98 ✗ }
99
100 ✗ MeasureTimeStatistic::MeasureTimeStatistic() : MeasureTimeRDTSC()
101 {
102 ✗ }
103
104 ✗ MeasureTimeStatistic::~MeasureTimeStatistic()
105 {
106 ✗ }
107
108 ✗ MeasureTimeValues* MeasureTimeStatistic::getZeroValuesP() const
109 {
110 ✗ return new MeasureTimeValuesStatistic(0ull);
111 }
112
113