void printEntries(std::ostream& o, const std::vector<Entry*>& entries, const std::string& indent, double parent_time) { if (parent_time <= 0.0) { parent_time = 0.0; for (size_t i = 0; i < entries.size(); ++i) { parent_time += entries[i]->time; } } double t_tot = 0.0; for (size_t i = 0; i < entries.size(); ++i) { const Entry* entry = entries[i]; std::ostringstream r; r << indent; std::string str = names[entry->id]; if (str.empty()) { r << "(" << entry->id << ")"; } else { r << str; } r << " "; std::string pad(r.str().size(), ' '); r << " - exectime: " << entry->time << "s (" << (entry->time * 100.0 / parent_time) << "%)" << std::endl; if (entry->allocTotal || entry->memoryDiff) { r << pad << " - alloc: " << formatMemory(entry->allocTotal) << " delta: " << formatMemory(entry->memoryDiff) << std::endl; r << pad << " - alloc blks:"; for (int i = 0; i < 32; i++) { if (entry->delta_blk_cnt_total[i]) r << ' ' << ((1 << (i - 1)) + 1) << '-' << (1 << i) << ':' << entry->delta_blk_cnt_total[i]; } r << std::endl; r << pad << " - delta blks:"; for (int i = 0; i < 32; i++) { if (entry->delta_blk_cnt_curr[i]) r << ' ' << ((1 << (i - 1)) + 1) << '-' << (1 << i) << ':' << entry->delta_blk_cnt_curr[i]; } r << std::endl; } o << r.str(); t_tot += entry->time; if (entry->children.size()) printEntries(o, entry->children, indent + " ", entry->time); } if (t_tot < parent_time) { o << indent << "*** unaccounted: " << (parent_time - t_tot) << "s (" << (100.0 - t_tot * 100.0 / parent_time) << "%)" << std::endl; } }
CDictionary::CDictionary(crstring fname) { CHECK_TIME("Constructing dictionary - total"); prepareMemory(fname); //alokacja readFile(fname); //przerzucenie zawartosci pliku formatMemory(); //konwersja do ciagu c-stringow (separacja NULLami) buildWordlist(); //budowa zbioru slow sortWordlist(); //ulozenie slow w naszym porzadku validateWordlist(); //sprawdzenie, czy sa po kolei dictionary = this; }