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