- Timestamp:
- Feb 22, 2017, 2:30:18 PM (7 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:
- 0788b739
- Parents:
- e58dfb9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeTools/DeclStats.cc
re58dfb9 reed5e48 62 62 std::map<unsigned, unsigned> p_basic; ///< Count of decls with each percentage of basic type elements 63 63 std::map<unsigned, unsigned> p_poly; ///< Count of decls with each percentage of polymorphic elements 64 VectorMap<unsigned> n_types; ///< Count of decls with each number of distinct types in the pack 64 65 65 66 ArgPackStats& operator+= (const ArgPackStats& o) { … … 69 70 sum(p_basic, o.p_basic); 70 71 sum(p_poly, o.p_poly); 72 sum(n_types, o.n_types); 71 73 72 74 return *this; … … 121 123 /// Update arg pack stats based on a declaration list 122 124 void analyze( Stats& stats, ArgPackStats& pstats, std::list<DeclarationWithType*>& decls ) { 125 std::unordered_set<std::string> types; 123 126 unsigned n = 0; 124 127 unsigned n_basic = 0; 125 128 unsigned n_poly = 0; 126 129 for ( auto decl : decls ) { 127 n += decl->get_type()->size(); 128 if ( BasicType* bt = dynamic_cast<BasicType*>( decl->get_type() ) ) { 130 Type* dt = decl->get_type(); 131 132 n += dt->size(); 133 134 std::stringstream ss; 135 dt->print( ss ); 136 types.insert( ss.str() ); 137 138 if ( dynamic_cast<BasicType*>( dt ) ) { 129 139 ++n_basic; 130 std::stringstream ss;131 bt->print( ss );132 140 ++stats.basic_type_names[ ss.str() ]; 133 } else if ( GenPoly::hasPolyBase( d ecl->get_type()) ) {141 } else if ( GenPoly::hasPolyBase( dt ) ) { 134 142 ++n_poly; 135 143 } else { 136 std::stringstream ss;137 decl->get_type()->print( ss );138 144 ++stats.compound_type_names[ ss.str() ]; 139 145 } … … 146 152 ++pstats.p_poly[ n_poly*100/n ]; 147 153 } 154 ++pstats.n_types.at( types.size() ); 148 155 } 149 156 … … 267 274 printAllMap("%_basic_" + name, [&extract](const Stats& stats) { return extract(stats).p_basic; }); 268 275 printAllMap("%_poly_" + name, [&extract](const Stats& stats) { return extract(stats).p_poly; }); 276 printAllMap("n_distinct_types_" + name, [&extract](const Stats& stats) { return extract(stats).n_types; }); 269 277 } 270 278
Note: See TracChangeset
for help on using the changeset viewer.