Version: 9.15.0
chrono.hxx
Go to the documentation of this file.
1
// Copyright (C) 2006-2025 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
#ifndef _CHRONO_HXX_
21
#define _CHRONO_HXX_
22
23
#include "
YACSBasesExport.hxx
"
24
25
#include <vector>
26
#include <string>
27
#include <iostream>
28
#include <ctime>
29
#ifdef WIN32
30
#else
31
#include <sys/time.h>
32
#endif
33
34
typedef
struct
acnt
35
{
36
char
*
_ctrNames
;
37
int
_ctrLines
;
38
int
_ctrOccur
;
39
double
_ctrCumul
;
40
}
cntStruct
;
41
42
class
YACSBASES_EXPORT
counters
43
{
44
public
:
45
static
cntStruct
*
_ctrs
;
46
counters
(
int
nb);
47
~
counters
();
48
void
stats();
49
protected
:
50
int
_nbChrono
;
51
};
52
53
class
YACSBASES_EXPORT
salome_chrono
54
{
55
public
:
56
salome_chrono
(
int
i
);
57
~
salome_chrono
();
58
void
stop();
59
protected
:
60
bool
_run
;
61
int
_ctr
;
62
clock_t _start,
_end
;
63
};
64
65
#ifndef START_TIMING
66
static
long
tcount
=0;
67
static
long
cumul
;
68
#ifdef WIN32
69
static
time_t
tv
;
70
#else
71
static
timeval
tv
;
72
#endif
73
#define START_TIMING gettimeofday(&tv,0);long tt0=tv.tv_usec+tv.tv_sec*1000000;
74
#define END_TIMING(NUMBER) \
75
tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \
76
if(tcount==NUMBER){ std::cerr << __FILE__<<":"
<<__LINE__<<" temps CPU(mus): "<<cumul<< std::endl; tcount=0 ;cumul=0; }
77
#endif
78
79
#ifdef CHRONODEF
80
#define CHRONO(i) counters::_ctrs[i]._ctrNames = (char *)__FILE__; \
81
counters::_ctrs[i]._ctrLines = __LINE__; \
82
salome_chrono aChrono##i(i);
83
84
#define CHRONOSTOP(i) aChrono##i.stop();
85
86
#else
// CHRONODEF
87
88
#define CHRONO(i)
89
#define CHRONOSTOP(i)
90
91
#endif
// CHRONODEF
92
93
#endif
// _CHRONO_HXX_
YACSBasesExport.hxx
YACSBASES_EXPORT
#define YACSBASES_EXPORT
Definition:
YACSBasesExport.hxx:31
cntStruct
struct acnt cntStruct
cumul
static long cumul
Definition:
chrono.hxx:67
tv
static timeval tv
Definition:
chrono.hxx:71
tcount
static long tcount
Definition:
chrono.hxx:66
counters
Definition:
chrono.hxx:43
counters::_ctrs
static cntStruct * _ctrs
Definition:
chrono.hxx:45
counters::_nbChrono
int _nbChrono
Definition:
chrono.hxx:50
salome_chrono
Definition:
chrono.hxx:54
salome_chrono::_end
clock_t _end
Definition:
chrono.hxx:62
salome_chrono::_ctr
int _ctr
Definition:
chrono.hxx:61
salome_chrono::_run
bool _run
Definition:
chrono.hxx:60
yacsorb.CORBAEngineTest.i
int i
Definition:
CORBAEngineTest.py:50
acnt
Definition:
chrono.hxx:35
acnt::_ctrLines
int _ctrLines
Definition:
chrono.hxx:37
acnt::_ctrCumul
double _ctrCumul
Definition:
chrono.hxx:39
acnt::_ctrOccur
int _ctrOccur
Definition:
chrono.hxx:38
acnt::_ctrNames
char * _ctrNames
Definition:
chrono.hxx:36
src
bases
chrono.hxx
Copyright © 2006-2024 CEA, EDF