Changeset 567903e


Ignore:
Timestamp:
Feb 6, 2017, 11:54:48 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:
6a5f0e7
Parents:
0c82fec4
Message:

Added percentage polymorphic parameters to stats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeTools/DeclStats.cc

    r0c82fec4 r567903e  
    1717
    1818#include <iostream>
     19#include <map>
    1920#include <string>
    2021#include <unordered_map>
     
    4445                        /// Count of declarations with each number of polymorphic return types
    4546                        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() {}
    4853
    4954                        Stats& operator+= (const Stats& o) {
     
    7681                                }
    7782
     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
    7891                                return *this;
    7992                        }
     
    108121                        ++stats.by_params.at( n_params );
    109122                        ++stats.n_poly_params.at( n_poly_params );
     123                        if ( n_params > 0 ) ++stats.p_poly_params[ n_poly_params*100/n_params ];
    110124
    111125                        unsigned n_returns = 0;
     
    117131                        ++stats.by_returns.at( n_returns );
    118132                        ++stats.n_poly_returns.at( n_poly_returns );
     133                        if ( n_returns > 0 ) ++stats.p_poly_returns[ n_poly_returns*100/n_returns ];
    119134                }
    120135
     
    183198                        printAllMap("n_poly_params", [](const Stats& stats) { return stats.n_poly_params; });
    184199                        printAllMap("n_params", [](const Stats& stats) { return stats.by_params; });
     200                        printAllMap("%_poly_params", [](const Stats& stats) { return stats.p_poly_params; });
    185201                        printAllMap("n_poly_returns", [](const Stats& stats) { return stats.n_poly_returns; });
    186202                        printAllMap("n_returns", [](const Stats& stats) { return stats.by_returns; });
     203                        printAllMap("%_poly_returns", [](const Stats& stats) { return stats.p_poly_returns; });
    187204                }
    188205        };
Note: See TracChangeset for help on using the changeset viewer.