Changeset ecaeac6e


Ignore:
Timestamp:
May 3, 2018, 5:15:41 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
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, with_gc
Children:
a96691d
Parents:
01690b7
Message:

Better statistics formatting

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Common/Heap.cc

    r01690b7 recaeac6e  
    1414//
    1515
     16#include <cassert>
     17#include <cmath>
    1618#include <cstddef>
    17 #include <cassert>
     19#include <cstring>
    1820#include <iomanip>
    1921#include <iostream>
     
    4547
    4648                void printStats() {
    47                         std::cerr << "Heap usage statistic:" << std::endl;
    48                         std::cerr << "Pass                 | Malloc Count |   Free Count" << std::endl;
     49                        size_t nc = 0;
    4950                        for(size_t i = 0; i < passes_cnt; i++) {
    50                                 std::cerr << std::setw(20) << passes[i].name    << " | ";
     51                                nc = std::max(nc, std::strlen(passes[i].name));
     52                        }
     53
     54                        const char * const title = "Heap Usage Statistic";
     55                        for(size_t i = 0; i < (nc + 30); i++) std::cerr << '='; std::cerr << '\n';
     56                        for(size_t i = 0; i < (nc + 30 - std::strlen(title)) / 2; i++) std::cerr << ' ';
     57                        std::cerr << title << std::endl;
     58                        for(size_t i = 0; i < (nc + 30); i++) std::cerr << '-'; std::cerr << '\n';
     59                        std::cerr << std::setw(nc) << "Pass";
     60                        std::cerr << " | Malloc Count |   Free Count" << std::endl;
     61                        for(size_t i = 0; i < (nc + 30); i++) std::cerr << '-'; std::cerr << '\n';
     62                        for(size_t i = 0; i < passes_cnt; i++) {
     63                                std::cerr << std::setw(nc) << passes[i].name    << " | ";
    5164                                std::cerr << std::setw(12) << passes[i].mallocs << " | ";
    5265                                std::cerr << std::setw(12) << passes[i].frees   << "\n";
  • src/main.cc

    r01690b7 recaeac6e  
    6464
    6565#define PASS(name, pass)                   \
    66         if ( errorp ) { cerr << #name << endl; } \
    67         HeapStats::newPass(#name);               \
     66        if ( errorp ) { cerr << name << endl; } \
     67        HeapStats::newPass(name);               \
    6868        pass;
    6969
Note: See TracChangeset for help on using the changeset viewer.