source: trunk/IPs/systemC/processor/Morpheo/Behavioural/src/Stat.cpp @ 146

Last change on this file since 146 was 139, checked in by rosiere, 14 years ago
  • Add test for all configuration
  • RAT : add rat scheme (depth_save)
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1#ifdef STATISTICS
2#include "Behavioural/include/Stat.h"
3
4namespace morpheo {
5namespace behavioural {
6
7  Stat::Stat (std::string             name_instance,
8              std::string             name_component,
9              Parameters_Statistics * param):
10    _name_instance         (name_instance),
11    _name_component        (name_component),
12    _nb_cycle_before_begin (static_cast<cycle_t>(param->_nb_cycle_before_begin)),
13    _period                (static_cast<cycle_t>(param->_period_save)),
14    _save_periodic         (_period>0)
15  {
16    _generate_file = true;
17
18    _list_operand         = new std::map<std::string, var_t>;
19    _list_expr_per_cycle  = new std::list<expr_t>;
20    _list_expr_per_period = new std::list<expr_t>;
21    _list_stat            = new std::list<Stat *>;
22    _list_counters        = new std::list<counters_t *>;
23
24    _cycle                = create_variable("cycle");
25//  _cycle                = create_counter("cycle","","");
26    *_cycle               = 0; // for the first period
27  }
28
29  Stat::Stat (std::string name_instance,
30              std::string name_component,
31              cycle_t     nb_cycle_before_begin,
32              cycle_t     period):
33    _name_instance         (name_instance),
34    _name_component        (name_component),
35    _nb_cycle_before_begin (nb_cycle_before_begin),
36    _period                (period),
37    _save_periodic         (period>0)
38  {
39    _generate_file = true;
40
41    _list_operand         = new std::map<std::string, var_t>;
42    _list_expr_per_cycle  = new std::list<expr_t>;
43    _list_expr_per_period = new std::list<expr_t>;
44    _list_stat            = new std::list<Stat *>;
45    _list_counters        = new std::list<counters_t *>;
46
47    _cycle                = create_variable("cycle");
48//  _cycle                = create_counter("cycle","","");
49    *_cycle               = 0; // for the first period
50  }
51
52  Stat::~Stat (void)
53  {
54    if (_generate_file)
55      generate_file();
56
57    // parcourir la liste et desallouer les counters
58    for (std::map<std::string, var_t>::iterator i=_list_operand->begin();
59         i!= _list_operand->end();
60         ++i)
61      {
62        delete i->second.counter;
63      }
64    delete _list_operand;
65
66    // parcourir la liste et desallouer les arbres
67    for (std::list<expr_t>::iterator i=_list_expr_per_cycle->begin();
68         i!= _list_expr_per_cycle->end();
69         ++i)
70      {
71        delete i->expression;
72      }
73    delete _list_expr_per_cycle;
74
75    for (std::list<expr_t>::iterator i=_list_expr_per_period->begin();
76         i!= _list_expr_per_period->end();
77         ++i)
78      {
79        delete i->expression;
80      }
81    delete _list_expr_per_period;
82
83    // parcourir la liste et desallouer les arbres
84    for (std::list<counters_t*>::iterator i=_list_counters->begin();
85         i!= _list_counters->end();
86         ++i)
87      {
88        delete *i;
89      }
90    delete _list_counters;
91
92    delete _list_stat;
93  }
94};
95};
96#endif
Note: See TracBrowser for help on using the repository browser.