Changeset 6215a5c


Ignore:
Timestamp:
Feb 6, 2017, 11:37:38 AM (7 years ago)
Author:
Aaron Moss <a3moss@…>
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:
0c82fec4
Parents:
7a560c1
Message:

Added polymorphic stats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeTools/DeclStats.cc

    r7a560c1 r6215a5c  
    2222
    2323#include "Common/VectorMap.h"
     24#include "GenPoly/GenPoly.h"
    2425#include "Parser/LinkageSpec.h"
    2526#include "SynTree/Declaration.h"
     
    3940                        /// Count of declarations with each number of return types
    4041                        VectorMap<unsigned> by_returns;
    41 
    42                         Stats() : n_decls(0), mono_decls(0), poly_decls(0), by_name() {}
     42                        /// Count of declarations with each number of polymorphic parameters
     43                        VectorMap<unsigned> n_poly_params;
     44                        /// Count of declarations with each number of polymorphic return types
     45                        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() {}
    4348
    4449                        Stats& operator+= (const Stats& o) {
     
    6166                                }
    6267
     68                                n_poly_params.reserve( o.n_poly_params.size() );
     69                                for ( unsigned i = 0; i < o.n_poly_params.size(); ++i ) {
     70                                        n_poly_params[i] += o.n_poly_params[i];
     71                                }
     72
     73                                n_poly_returns.reserve( o.n_poly_returns.size() );
     74                                for ( unsigned i = 0; i < o.n_poly_returns.size(); ++i ) {
     75                                        n_poly_returns[i] += o.n_poly_returns[i];
     76                                }
     77
    6378                                return *this;
    6479                        }
     
    86101
    87102                        unsigned n_params = 0;
    88                         for ( auto pdecl : fnTy->get_parameters() ) { n_params += pdecl->get_type()->size(); }
     103                        unsigned n_poly_params = 0;
     104                        for ( auto pdecl : fnTy->get_parameters() ) {
     105                                n_params += pdecl->get_type()->size();
     106                                if ( GenPoly::hasPolyBase( pdecl->get_type() ) ) ++n_poly_params;
     107                        }
    89108                        ++stats.by_params.at( n_params );
     109                        ++stats.n_poly_params.at( n_poly_params );
    90110
    91111                        unsigned n_returns = 0;
    92                         for ( auto rdecl : fnTy->get_returnVals() ) { n_returns += rdecl->get_type()->size(); }
     112                        unsigned n_poly_returns = 0;
     113                        for ( auto rdecl : fnTy->get_returnVals() ) {
     114                                n_returns += rdecl->get_type()->size();
     115                                if ( GenPoly::hasPolyBase( rdecl->get_type() ) ) ++n_poly_returns;
     116                        }
    93117                        ++stats.by_returns.at( n_returns );
     118                        ++stats.n_poly_returns.at( n_poly_returns );
    94119                }
    95120
     
    156181
    157182                        printAllHisto("overloads", [](const Stats& stats) { return stats.by_name; });
     183                        printAllMap("n_poly_params", [](const Stats& stats) { return stats.n_poly_params; });
    158184                        printAllMap("n_params", [](const Stats& stats) { return stats.by_params; });
     185                        printAllMap("n_poly_returns", [](const Stats& stats) { return stats.n_poly_returns; });
    159186                        printAllMap("n_returns", [](const Stats& stats) { return stats.by_returns; });
    160187                }
Note: See TracChangeset for help on using the changeset viewer.