Changeset 1232


Ignore:
Timestamp:
Oct 23, 2010, 4:06:06 PM (11 years ago)
Author:
Peter Johansson
Message:

refs #476. Reset stats when it's no longer needed (to save
memory). Added a new class TinyStats? that holds information about the
latest revision and is created from the CollectionStats?.

Location:
branches/visitor/lib
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/visitor/lib/CopyrightVisitor.cc

    r1229 r1232  
    5757    file.parse(verbose_, ignore_cache_);
    5858    file.print_copyright(alias_, verbose_, year2rev_);
     59    file.stats().reset();
    5960  }
    6061
  • branches/visitor/lib/Directory.cc

    r1230 r1232  
    3030#include "SVN.h"
    3131#include "SVNlog.h"
     32#include "TinyStats.h"
    3233#include "utility.h"
    3334
     
    101102
    102103
    103   bool Directory::dir(void) const
    104   {
    105     return true;
    106   }
    107 
    108 
    109104  void Directory::gather_stats(void)
    110105  {
    111106    stats_.reset();
    112107    for (NodeIterator i=daughters_.begin(); i!=daughters_.end(); ++i)
    113       if (!(*i)->ignore())
     108      if (!(*i)->ignore()) {
    114109        stats_ += (*i)->stats();
     110        (*i)->stats().reset();
     111      }
     112  }
     113
     114
     115  bool Directory::dir(void) const
     116  {
     117    return true;
    115118  }
    116119
     
    151154  {
    152155    stats_.reset();
     156    assert(0 && "we are not using this function, are we?");
    153157    /*
    154158    for (NodeIterator i=daughters_.begin(); i!=daughters_.end(); ++i)
  • branches/visitor/lib/Directory.h

    r1230 r1232  
    6161    ~Directory(void);
    6262
     63    /**
     64       Collect stats from daughter nodes and reset stats in daughter
     65       nodes.
     66     */
     67    void collect_stats(void);
     68
    6369    ///
    6470    /// @return true
    6571    ///
    6672    bool dir(void) const;
    67 
    68     /**
    69        Collect stats from daughter nodes.
    70      */
    71     void gather_stats(void);
    7273
    7374    ///
  • branches/visitor/lib/File.cc

    r1230 r1232  
    3434#include "SVNblame.h"
    3535#include "SVNlog.h"
     36#include "TinyStats.h"
    3637
    3738#include <algorithm>
  • branches/visitor/lib/Makefile.am

    r1230 r1232  
    3939  Stats.h StatsCollection.h subversion_info.h \
    4040  SvndigestVisitor.h SVN.h SVNblame.h \
    41   SVNdiff.h SVNinfo.h SVNlog.h SVNproperty.h Trac.h utility.h Vector.h
     41  SVNdiff.h SVNinfo.h SVNlog.h SVNproperty.h TinyStats.h \
     42  Trac.h utility.h Vector.h
    4243
    4344libsvndigest_a_SOURCES = AddStats.cc Alias.cc BlameStats.cc \
     
    5051  rmdirhier.cc Stats.cc StatsCollection.cc subversion_info.cc SVN.cc \
    5152  SVNblame.cc SVNdiff.cc SvndigestVisitor.cc SVNinfo.cc \
    52   SVNlog.cc SVNproperty.cc \
     53  SVNlog.cc SVNproperty.cc TinyStats.cc \
    5354  Trac.cc utility.cc Vector.cc
    5455
  • branches/visitor/lib/Node.cc

    r1230 r1232  
    2727#include "HtmlStream.h"
    2828#include "html_utility.h"
     29#include "LineTypeParser.h"
    2930#include "SVNlog.h"
    3031#include "SVNproperty.h"
     
    9596                           const std::string& user) const
    9697  {
    97     const Stats& stats = stats_[stats_type];
    9898    os << "<tr class=\"" << css_class << "\">\n"
    9999       << "<td class=\"" << node_type() << "\">";
     
    105105      os << name() << " (<i>link</i>)";
    106106    // there is no output for nodes when user has zero contribution
    107     else if (user!="all" && !stats.lines(user))
     107    else if (user!="all" && !tiny_stats_(stats_type,user,LineTypeParser::total))
    108108      os << name();
    109109    else if (!Configuration::instance().output_file() && !this->dir())
     
    112112      os << anchor(href(), name());
    113113    os << "</td>\n";
    114     if (user=="all") {
    115       os << "<td>" << stats.lines() << "</td>\n"
    116          << "<td>" << stats.code() << "</td>\n"
    117          << "<td>" << stats.comments() << "</td>\n"
    118          << "<td>" << stats.empty() << "</td>\n";
    119     }
    120     else {
    121       os << "<td>" << stats.lines(user);
    122       if (stats.lines(user))
    123         os << " (" << percent(stats.lines(user),stats.lines()) << "%)";
    124       os << "</td>\n";
    125       os << "<td>" << stats.code(user);
    126       if (stats.code(user))
    127         os << " (" << percent(stats.code(user),stats.code()) << "%)";
    128       os << "</td>\n";
    129       os << "<td>" << stats.comments(user);
    130       if (stats.comments(user))
    131         os << " (" << percent(stats.comments(user),stats.comments()) << "%)";
    132       os << "</td>\n";
    133       os << "<td>" << stats.empty(user);
    134       if (stats.empty(user))
    135         os << " (" << percent(stats.empty(user),stats.empty()) << "%)";
    136       os << "</td>\n";
    137 
    138     }
    139 
     114
     115    std::cerr << "table row: " << path() << std::endl;
     116
     117    html_tabletd(os, stats_type, user, LineTypeParser::total);
     118    html_tabletd(os, stats_type, user, LineTypeParser::code);
     119    html_tabletd(os, stats_type, user, LineTypeParser::comment);
     120    html_tabletd(os, stats_type, user, LineTypeParser::other);
     121   
    140122    os << "<td>" << trac_revision(last_changed_rev()) << "</td>\n"
    141123       << "<td>" << author() << "</td>\n"
    142124       << "</tr>\n";
     125  }
     126
     127
     128  void Node::html_tabletd(std::ostream& os, const std::string& stats_type,
     129                          const std::string& user,
     130                          LineTypeParser::line_type lt) const
     131  {
     132    os << "<td>" << tiny_stats_(stats_type, user, lt);
     133    if (user!="all" && tiny_stats_(stats_type, user, lt))
     134      os << " (" << percent(tiny_stats_(stats_type, user, lt),
     135                            tiny_stats_(stats_type, "all", lt)) << "%)";
     136    os << "</td>\n";
     137  }
     138 
     139
     140  void Node::init_tiny_stats(void)
     141  {
     142    tiny_stats_.init(stats_);
    143143  }
    144144
     
    333333
    334334
     335  StatsCollection& Node::stats(void)
     336  {
     337    return stats_;
     338  }
     339
     340
    335341  bool Node::svncopyright_ignore(void) const
    336342  {
  • branches/visitor/lib/Node.h

    r1230 r1232  
    2626
    2727#include "html_utility.h"
     28#include "LineTypeParser.h"
    2829#include "StatsCollection.h"
    2930#include "SVNinfo.h"
    3031#include "SVNlog.h"
     32#include "TinyStats.h"
    3133#include "utility.h"
    3234
     
    109111    { return binary_ || svndigest_ignore_ || link_; }
    110112
     113    /**
     114       Create the TinyStats based on the stored CollectionStats
     115     */
     116    void init_tiny_stats(void);
     117
    111118    ///
    112119    /// @brief Get the revision number of the latest commit.
     
    203210     */
    204211    const StatsCollection& stats(void) const;
     212
     213    StatsCollection& stats(void);
    205214
    206215    /**
     
    228237    static std::string project_;
    229238    StatsCollection stats_;
     239    TinyStats tiny_stats_;
    230240
    231241  private:
     
    234244    ///
    235245    Node(const Node&);
     246
     247    void html_tabletd(std::ostream&, const std::string& stats_type,
     248                      const std::string& user,
     249                      LineTypeParser::line_type lt) const;
    236250
    237251    virtual void log_core(SVNlog&) const=0;
  • branches/visitor/lib/SvndigestVisitor.cc

    r1230 r1232  
    4646  {
    4747    if (report_) {
    48       dir.gather_stats();
     48      dir.collect_stats();
     49      dir.init_tiny_stats();
    4950      dir.print(verbose_);
    5051    }
     
    5455  void SvndigestVisitor::visit(File& file)
    5556  {
    56     if (file.ignore())
    57       return;
    58     file.parse(verbose_, ignore_cache_);
    59     if (report_)
    60       file.print(verbose_);
     57    if (!file.ignore())
     58      file.parse(verbose_, ignore_cache_);
     59    if (report_) {
     60      file.init_tiny_stats();
     61      if (!file.ignore())
     62        file.print(verbose_);
     63    }
    6164  }
    6265
Note: See TracChangeset for help on using the changeset viewer.