TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
StatComm.cpp
1/****************************************************************************
2* Copyright (c) 2022, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15#include <StatComm.h>
16#include <Nom.h>
17#include <SFichier.h>
18#include <fstream>
19
20static int* tab_comm;
21static int prem=1;
22
24{
25 SZ_MIN=32768;
26 SZ_MAX=0;
27 SZ_MOY=0.0;
28 nb_msg=0;
29}
30
31void StatComm::stat(int size)
32{
33 if(prem==1)
34 {
35 tab_comm = new int[10000];
36 for(int i=0; i<10000; i++)
37 tab_comm[i]=0;
38 prem=0;
39 }
40 if(size<10000)
41 tab_comm[size]++;
42
43 nb_msg++;
44 if(size>SZ_MAX) SZ_MAX=size;
45 if(size<SZ_MIN) SZ_MIN=size;
46 SZ_MOY+=(double)size;
47}
48
50{
51 return SZ_MIN;
52}
54{
55 return SZ_MAX;
56}
58{
59 if (nb_msg!=0)
60 return ((double)(SZ_MOY/(double)nb_msg)) ;
61 else
62 return 0.0;
63}
65{
66 return nb_msg;
67}
68
70{
71 if (prem==0)
72 {
73 Nom nf("COMM_");
74 nf+=Nom(Process::me());
75 nf+=".trace";
76 ofstream fic((const char *)nf,ios::out);
77 for(int i=0; i<10000; i++)
78 if(tab_comm[i]!=0)
79 fic<<i<<"\t"<<tab_comm[i]<<std::endl;
80 }
81 os<<"SZ_MIN : "<<SZ_MIN<<finl;
82 os<<"SZ_MAX : "<<SZ_MAX<<finl;
83 os<<"SZ_MOY : "<<get_szmoy()<<finl;
84 os<<"NB_MSG : "<<nb_msg<<finl;
85}
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
static int me()
renvoie mon rang dans le groupe de communication courant.
Definition Process.cpp:125
Classe de base des flux de sortie.
Definition Sortie.h:52
int get_nbmsg()
Definition StatComm.cpp:64
int get_szmax()
Definition StatComm.cpp:53
void stat(int size)
Definition StatComm.cpp:31
int get_szmin()
Definition StatComm.cpp:49
void print_stat(Sortie &os)
Definition StatComm.cpp:69
double get_szmoy()
Definition StatComm.cpp:57