Changeset 567903e
- Timestamp:
- Feb 6, 2017, 11:54:48 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 6a5f0e7
- Parents:
- 0c82fec4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeTools/DeclStats.cc
r0c82fec4 r567903e 17 17 18 18 #include <iostream> 19 #include <map> 19 20 #include <string> 20 21 #include <unordered_map> … … 44 45 /// Count of declarations with each number of polymorphic return types 45 46 VectorMap<unsigned> n_poly_returns; 46 47 Stats() : n_decls(0), mono_decls(0), poly_decls(0), by_name(), by_params(), by_returns(), n_poly_params(), n_poly_returns() {} 47 /// Count of declarations with each percentage of polymorphic parameters 48 std::map<unsigned, unsigned> p_poly_params; 49 /// Count of declarations with each percentage of polymorphic returns 50 std::map<unsigned, unsigned> p_poly_returns; 51 52 Stats() : n_decls(0), mono_decls(0), poly_decls(0), by_name(), by_params(), by_returns(), n_poly_params(), n_poly_returns(), p_poly_params(), p_poly_returns() {} 48 53 49 54 Stats& operator+= (const Stats& o) { … … 76 81 } 77 82 83 for ( const auto& entry : o.p_poly_params ) { 84 p_poly_params[ entry.first ] += entry.second; 85 } 86 87 for ( const auto& entry : o.p_poly_returns ) { 88 p_poly_returns[ entry.first ] += entry.second; 89 } 90 78 91 return *this; 79 92 } … … 108 121 ++stats.by_params.at( n_params ); 109 122 ++stats.n_poly_params.at( n_poly_params ); 123 if ( n_params > 0 ) ++stats.p_poly_params[ n_poly_params*100/n_params ]; 110 124 111 125 unsigned n_returns = 0; … … 117 131 ++stats.by_returns.at( n_returns ); 118 132 ++stats.n_poly_returns.at( n_poly_returns ); 133 if ( n_returns > 0 ) ++stats.p_poly_returns[ n_poly_returns*100/n_returns ]; 119 134 } 120 135 … … 183 198 printAllMap("n_poly_params", [](const Stats& stats) { return stats.n_poly_params; }); 184 199 printAllMap("n_params", [](const Stats& stats) { return stats.by_params; }); 200 printAllMap("%_poly_params", [](const Stats& stats) { return stats.p_poly_params; }); 185 201 printAllMap("n_poly_returns", [](const Stats& stats) { return stats.n_poly_returns; }); 186 202 printAllMap("n_returns", [](const Stats& stats) { return stats.by_returns; }); 203 printAllMap("%_poly_returns", [](const Stats& stats) { return stats.p_poly_returns; }); 187 204 } 188 205 };
Note: See TracChangeset
for help on using the changeset viewer.