Changeset 131dbb3
- Timestamp:
- Feb 24, 2017, 4:00:42 PM (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:
- 356c62a
- Parents:
- 396ee0a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeTools/DeclStats.cc
r396ee0a r131dbb3 63 63 std::map<unsigned, unsigned> p_poly; ///< Count of decls with each percentage of polymorphic elements 64 64 VectorMap<unsigned> n_types; ///< Count of decls with each number of distinct types in the pack 65 /// Count of decls with each percentage of new types in lists. 66 /// Types used in the parameter list that recur in the return list are not considered to be new. 67 std::map<unsigned, unsigned> p_new; 65 68 66 69 ArgPackStats& operator+= (const ArgPackStats& o) { … … 71 74 sum(p_poly, o.p_poly); 72 75 sum(n_types, o.n_types); 76 sum(p_new, o.p_new); 73 77 74 78 return *this; … … 86 90 /// Count of uses of each non-basic type 87 91 std::unordered_map<std::string, unsigned> compound_type_names; 92 /// Count of decls using each basic type 93 std::unordered_map<std::string, unsigned> basic_type_decls; 94 /// Count of decls using each compound type 95 std::unordered_map<std::string, unsigned> compound_type_decls; 88 96 /// Stats for the parameter list 89 97 ArgPackStats params; … … 98 106 ArgPackStats assn_returns; 99 107 100 Stats() : n_decls(0), n_type_params(), by_name(), basic_type_names(), compound_type_names(), params(), returns(), n_assns(), assn_params(), assn_returns() {}108 Stats() : n_decls(0), n_type_params(), by_name(), basic_type_names(), compound_type_names(), basic_type_decls(), compound_type_decls(), params(), returns(), n_assns(), assn_params(), assn_returns() {} 101 109 102 110 public: … … 107 115 sum( basic_type_names, o.basic_type_names ); 108 116 sum( compound_type_names, o.compound_type_names ); 117 sum( basic_type_decls, o.basic_type_decls ); 118 sum( compound_type_decls, o.compound_type_decls ); 109 119 sum( params, o.params ); 110 120 sum( returns, o.returns ); … … 122 132 123 133 /// Update arg pack stats based on a declaration list 124 void analyze( Stats& stats, ArgPackStats& pstats, std::list<DeclarationWithType*>& decls ) {134 void analyze( Stats& stats, std::unordered_set<std::string>& seen, ArgPackStats& pstats, std::list<DeclarationWithType*>& decls ) { 125 135 std::unordered_set<std::string> types; 126 unsigned n = 0; 127 unsigned n_basic = 0; 128 unsigned n_poly = 0; 136 unsigned n = 0; ///< number of args/returns 137 unsigned n_basic = 0; ///< number of basic types 138 unsigned n_poly = 0; ///< number of polymorphic types 139 unsigned n_new = 0; ///< number of new types 129 140 for ( auto decl : decls ) { 130 141 Type* dt = decl->get_type(); … … 135 146 dt->print( ss ); 136 147 types.insert( ss.str() ); 148 bool this_new = seen.insert( ss.str() ).second; 149 if ( this_new ) { ++n_new; } 137 150 138 151 if ( dynamic_cast<BasicType*>( dt ) ) { 139 152 ++n_basic; 140 153 ++stats.basic_type_names[ ss.str() ]; 154 if ( this_new ) { 155 ++stats.basic_type_decls[ ss.str() ]; 156 } 141 157 } else if ( GenPoly::hasPolyBase( dt ) ) { 142 158 ++n_poly; 143 159 } else { 144 160 ++stats.compound_type_names[ ss.str() ]; 161 if ( this_new ) { 162 ++stats.compound_type_decls[ ss.str() ]; 163 } 145 164 } 146 165 } … … 151 170 ++pstats.p_basic[ n_basic*100/n ]; 152 171 ++pstats.p_poly[ n_poly*100/n ]; 172 ++pstats.p_new[ n_new*100/n ]; 153 173 } 154 174 ++pstats.n_types.at( types.size() ); … … 156 176 157 177 void analyzeFunc( FunctionType* fnTy, Stats& stats, ArgPackStats& params, ArgPackStats& returns ) { 158 analyze( stats, params, fnTy->get_parameters() ); 159 analyze( stats, returns, fnTy->get_returnVals() ); 178 std::unordered_set<std::string> seen; 179 analyze( stats, seen, params, fnTy->get_parameters() ); 180 analyze( stats, seen, returns, fnTy->get_returnVals() ); 160 181 } 161 182 … … 275 296 printAllMap("%_poly_" + name, [&extract](const Stats& stats) { return extract(stats).p_poly; }); 276 297 printAllMap("n_distinct_types_" + name, [&extract](const Stats& stats) { return extract(stats).n_types; }); 298 printAllMap("%_new_types_in_" + name, [&extract](const Stats& stats) { return extract(stats).p_new; }); 277 299 } 278 300 … … 291 313 printAll("basic_type_names", [](const Stats& stats) { return stats.basic_type_names.size(); }); 292 314 printAllSparseHisto("basic_type_uses", [](const Stats& stats) { return stats.basic_type_names; }); 315 printAllSparseHisto("decls_using_basic_type", [](const Stats& stats) { return stats.basic_type_decls; }); 293 316 printAll("compound_type_names", [](const Stats& stats) { return stats.compound_type_names.size(); }); 294 317 printAllSparseHisto("compound_type_uses", [](const Stats& stats) { return stats.compound_type_names; }); 318 printAllSparseHisto("decls_using_compound_type", [](const Stats& stats) { return stats.compound_type_decls; }); 295 319 printAllPack("params", [](const Stats& stats) { return stats.params; }); 296 320 printAllPack("returns", [](const Stats& stats) { return stats.returns; });
Note: See TracChangeset
for help on using the changeset viewer.