1 | #ifdef STATISTICS |
---|
2 | #include "Behavioural/include/Stat.h" |
---|
3 | |
---|
4 | namespace morpheo { |
---|
5 | namespace behavioural { |
---|
6 | |
---|
7 | void Stat::create_expr (std::string varname, |
---|
8 | std::string expr, |
---|
9 | bool each_cycle) |
---|
10 | { |
---|
11 | if (is_valid_var (varname)) |
---|
12 | throw(ERRORMORPHEO("Stat::create_expr",_("Variable is not valid."))); |
---|
13 | |
---|
14 | expr_t expression; |
---|
15 | |
---|
16 | expression.variable = (*_list_operand) [varname].counter; |
---|
17 | expression.expression = string2tree(expr); |
---|
18 | expression.each_cycle = each_cycle; |
---|
19 | |
---|
20 | _list_expr->push_back(expression); |
---|
21 | } |
---|
22 | |
---|
23 | void Stat::create_expr (std::string varname, |
---|
24 | std::string expr, |
---|
25 | counter_type_t type, |
---|
26 | std::string unit, |
---|
27 | std::string description, |
---|
28 | bool each_cycle) |
---|
29 | { |
---|
30 | if (type == TYPE_COUNTER) |
---|
31 | create_counter (varname,unit,description); |
---|
32 | else |
---|
33 | create_variable(varname); |
---|
34 | |
---|
35 | create_expr(varname, expr, each_cycle); |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | void Stat::create_expr_average (std::string varname, |
---|
40 | std::string expr_sum, |
---|
41 | std::string expr_deps, |
---|
42 | std::string unit, |
---|
43 | std::string description) |
---|
44 | { |
---|
45 | create_counter(varname,unit,description); |
---|
46 | create_expr (varname, "/ "+expr_sum+" "+expr_deps, false); |
---|
47 | } |
---|
48 | |
---|
49 | void Stat::create_expr_average_by_cycle (std::string varname, |
---|
50 | std::string expr_sum, |
---|
51 | std::string unit, |
---|
52 | std::string description) |
---|
53 | { |
---|
54 | create_expr_average (varname, expr_sum, "cycle", unit, description); |
---|
55 | } |
---|
56 | |
---|
57 | void Stat::create_expr_percent (std::string varname, |
---|
58 | std::string expr_sum, |
---|
59 | std::string expr_max, |
---|
60 | std::string description) |
---|
61 | { |
---|
62 | create_counter(varname,"%",description); |
---|
63 | create_expr (varname, "/ * "+expr_sum+" 100 "+expr_max, false); |
---|
64 | } |
---|
65 | |
---|
66 | |
---|
67 | }; |
---|
68 | }; |
---|
69 | #endif |
---|