Changeset 53bb8f1 for src/SymTab/Indexer.cc
- Timestamp:
- Mar 12, 2019, 3:00:54 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 30e32b2, a2545593
- Parents:
- 9d9a451 (diff), 91d6584 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Indexer.cc
r9d9a451 r53bb8f1 26 26 #include "Common/SemanticError.h" // for SemanticError 27 27 #include "Common/utility.h" // for cloneAll 28 #include "Common/Stats/Counter.h" // for counters 28 29 #include "GenPoly/GenPoly.h" 29 30 #include "InitTweak/InitTweak.h" // for isConstructor, isCopyFunction, isC... … … 41 42 42 43 namespace SymTab { 44 45 // Statistics block 46 namespace { 47 48 static inline auto stats_idtable() { 49 using namespace Stats::Counters; 50 static auto group = build<CounterGroup>("IdTable"); 51 static struct { 52 SimpleCounter * find; 53 AverageCounter<double> * size; 54 AverageCounter<double> * key; 55 } ret = { 56 .find = build<SimpleCounter>("Find calls", group), 57 .size = build<AverageCounter<double>>("Average Size", group), 58 .key = build<AverageCounter<double>>("Average Key Size", group), 59 }; 60 return ret; 61 } 62 63 static inline auto stats_indexers() { 64 using namespace Stats::Counters; 65 static auto group = build<CounterGroup>("Indexers"); 66 static struct { 67 SimpleCounter * count; 68 AverageCounter<double> * size; 69 AverageCounter<double> * depth_a; 70 MaxCounter<size_t> * depth_m; 71 } ret = { 72 .count = build<SimpleCounter>("Count", group), 73 .size = build<AverageCounter<double>>("Average Size", group), 74 .depth_a = build<AverageCounter<double>>("Average Depth", group), 75 .depth_m = build<MaxCounter<size_t>>("Max Depth", group), 76 }; 77 return ret; 78 } 79 } 80 43 81 std::ostream & operator<<( std::ostream & out, const Indexer::IdData & data ) { 44 82 return out << "(" << data.id << "," << data.baseExpr << ")"; … … 197 235 } 198 236 199 Indexer::Indexer() : tables( 0 ), scope( 0 ) {} 200 201 Indexer::Indexer( const Indexer &that ) : doDebug( that.doDebug ), tables( newRef( that.tables ) ), scope( that.scope ) {} 237 Indexer::Indexer() : tables( 0 ), scope( 0 ) { 238 (*stats_indexers().count)++; 239 } 240 241 Indexer::Indexer( const Indexer &that ) : doDebug( that.doDebug ), tables( newRef( that.tables ) ), scope( that.scope ) { 242 (*stats_indexers().count)++; 243 } 202 244 203 245 Indexer::Indexer( Indexer &&that ) : doDebug( that.doDebug ), tables( that.tables ), scope( that.scope ) { … … 206 248 207 249 Indexer::~Indexer() { 250 if(tables) { 251 stats_indexers().size->push( tables->idTable.size() ); 252 size_t depth = 1; 253 for( auto crnt = tables->base.tables; crnt; crnt = crnt->base.tables ) { 254 ++depth; 255 } 256 stats_indexers().depth_a->push( depth ); 257 stats_indexers().depth_m->push( depth ); 258 } 208 259 deleteRef( tables ); 209 260 } … … 237 288 while ( searchTables ) { 238 289 290 (*stats_idtable().find)++; 291 stats_idtable().key->push( id.size() ); 292 stats_idtable().size->push( searchTables->idTable.size() ); 239 293 IdTable::const_iterator decls = searchTables->idTable.find( id ); 240 294 if ( decls != searchTables->idTable.end() ) { … … 313 367 if ( tables->scope < scope ) return nullptr; 314 368 369 (*stats_idtable().find)++; 370 stats_idtable().key->push( id.size() ); 371 stats_idtable().size->push( tables->idTable.size() ); 315 372 IdTable::const_iterator decls = tables->idTable.find( id ); 316 373 if ( decls != tables->idTable.end() ) { … … 331 388 if ( tables->scope < scope ) return false; 332 389 390 (*stats_idtable().find)++; 391 stats_idtable().key->push( id.size() ); 392 stats_idtable().size->push( tables->idTable.size() ); 333 393 IdTable::const_iterator decls = tables->idTable.find( id ); 334 394 if ( decls != tables->idTable.end() ) { … … 347 407 if ( tables->scope < scope ) return false; 348 408 409 (*stats_idtable().find)++; 410 stats_idtable().key->push( id.size() ); 411 stats_idtable().size->push( tables->idTable.size() ); 349 412 IdTable::const_iterator decls = tables->idTable.find( id ); 350 413 if ( decls != tables->idTable.end() ) {
Note:
See TracChangeset
for help on using the changeset viewer.