Version: 9.16.0
chrono.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#include "chrono.hxx"
21
22//#define _DEVDEBUG_
23#include "YacsTrace.hxx"
24
25using namespace std;
26
28
30{
31 DEBTRACE("counters::counters(int nb)");
32 _nbChrono = nb;
34
35 for (int i=0; i< _nbChrono; i++)
36 {
37 _ctrs[i]._ctrNames = 0;
38 _ctrs[i]._ctrLines = 0;
39 _ctrs[i]._ctrOccur = 0;
40 _ctrs[i]._ctrCumul = 0;
41 }
42
43 DEBTRACE("counters::counters()");
44}
45
47{
48 stats();
49}
50
52{
53 DEBTRACE("counters::stats()");
54 for (int i=0; i < _nbChrono; i++)
55 if (_ctrs[i]._ctrOccur)
56 {
57 std::cerr << "Compteur[" << i << "]: "<< _ctrs[i]._ctrNames << "[" << _ctrs[i]._ctrLines << "]" << std::endl;
58 std::cerr << " " << _ctrs[i]._ctrOccur << std::endl;
59 std::cerr << " " << _ctrs[i]._ctrCumul << std::endl;
60 }
61}
62
63
64
65salome_chrono::salome_chrono(int i) : _ctr(i), _run(true)
66{
67 //DEBTRACE("salome_chrono::salome_chrono " << _ctr << " " << _run);
68 _start = clock();
69}
70
72{
73 if (_run) stop();
74}
75
77{
78 //DEBTRACE("salome_chrono::stop " << _ctr << " " << _run);
79 if (_run)
80 {
81 _run = false;
82 _end = clock();
83 double elapse = double(_end - _start)/double(CLOCKS_PER_SEC);
86 }
87}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
static cntStruct * _ctrs
Definition: chrono.hxx:45
int _nbChrono
Definition: chrono.hxx:50
counters(int nb)
Definition: chrono.cxx:29
void stats()
Definition: chrono.cxx:51
~counters()
Definition: chrono.cxx:46
void stop()
Definition: chrono.cxx:76
~salome_chrono()
Definition: chrono.cxx:71
salome_chrono(int i)
Definition: chrono.cxx:65
clock_t _start
Definition: chrono.hxx:62
clock_t _end
Definition: chrono.hxx:62
Definition: chrono.hxx:35
int _ctrLines
Definition: chrono.hxx:37
double _ctrCumul
Definition: chrono.hxx:39
int _ctrOccur
Definition: chrono.hxx:38
char * _ctrNames
Definition: chrono.hxx:36