Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeTools/DeclStats.cc

    r131dbb3 reed5e48  
    6363                        std::map<unsigned, unsigned> p_poly;   ///< Count of decls with each percentage of polymorphic elements
    6464                        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;
    6865
    6966                        ArgPackStats& operator+= (const ArgPackStats& o) {
     
    7471                                sum(p_poly, o.p_poly);
    7572                                sum(n_types, o.n_types);
    76                                 sum(p_new, o.p_new);
    7773                               
    7874                                return *this;
     
    9086                        /// Count of uses of each non-basic type
    9187                        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;
    9688                        /// Stats for the parameter list
    9789                        ArgPackStats params;
     
    10698                        ArgPackStats assn_returns;
    10799                       
    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() {}
     100                        Stats() : n_decls(0), n_type_params(), by_name(), basic_type_names(), compound_type_names(), params(), returns(), n_assns(), assn_params(), assn_returns() {}
    109101
    110102                public:
     
    115107                                sum( basic_type_names, o.basic_type_names );
    116108                                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 );
    119109                                sum( params, o.params );
    120110                                sum( returns, o.returns );
     
    132122
    133123                /// Update arg pack stats based on a declaration list
    134                 void analyze( Stats& stats, std::unordered_set<std::string>& seen, ArgPackStats& pstats, std::list<DeclarationWithType*>& decls ) {
     124                void analyze( Stats& stats, ArgPackStats& pstats, std::list<DeclarationWithType*>& decls ) {
    135125                        std::unordered_set<std::string> types;
    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
     126                        unsigned n = 0;
     127                        unsigned n_basic = 0;
     128                        unsigned n_poly = 0;
    140129                        for ( auto decl : decls ) {
    141130                                Type* dt = decl->get_type();
     
    146135                                dt->print( ss );
    147136                                types.insert( ss.str() );
    148                                 bool this_new = seen.insert( ss.str() ).second;
    149                                 if ( this_new ) { ++n_new; }
    150137
    151138                                if ( dynamic_cast<BasicType*>( dt ) ) {
    152139                                        ++n_basic;
    153140                                        ++stats.basic_type_names[ ss.str() ];
    154                                         if ( this_new ) {
    155                                                 ++stats.basic_type_decls[ ss.str() ];
    156                                         }
    157141                                } else if ( GenPoly::hasPolyBase( dt ) ) {
    158142                                        ++n_poly;
    159143                                } else {
    160144                                        ++stats.compound_type_names[ ss.str() ];
    161                                         if ( this_new ) {
    162                                                 ++stats.compound_type_decls[ ss.str() ];
    163                                         }
    164145                                }
    165146                        }
     
    170151                                ++pstats.p_basic[ n_basic*100/n ];
    171152                                ++pstats.p_poly[ n_poly*100/n ];
    172                                 ++pstats.p_new[ n_new*100/n ];
    173153                        }
    174154                        ++pstats.n_types.at( types.size() );
     
    176156               
    177157                void analyzeFunc( FunctionType* fnTy, Stats& stats, ArgPackStats& params, ArgPackStats& returns ) {
    178                         std::unordered_set<std::string> seen;
    179                         analyze( stats, seen, params, fnTy->get_parameters() );
    180                         analyze( stats, seen, returns, fnTy->get_returnVals() );
     158                        analyze( stats, params, fnTy->get_parameters() );
     159                        analyze( stats, returns, fnTy->get_returnVals() );
    181160                }
    182161
     
    296275                        printAllMap("%_poly_" + name, [&extract](const Stats& stats) { return extract(stats).p_poly; });
    297276                        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; });
    299277                }
    300278               
     
    313291                        printAll("basic_type_names", [](const Stats& stats) { return stats.basic_type_names.size(); });
    314292                        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; });
    316293                        printAll("compound_type_names", [](const Stats& stats) { return stats.compound_type_names.size(); });
    317294                        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; });
    319295                        printAllPack("params", [](const Stats& stats) { return stats.params; });
    320296                        printAllPack("returns", [](const Stats& stats) { return stats.returns; });
Note: See TracChangeset for help on using the changeset viewer.