Changeset 35 for trunk/lib/Stats.cc


Ignore:
Timestamp:
Jan 12, 2006, 5:12:14 PM (16 years ago)
Author:
Jari Häkkinen
Message:

Continued fixing gnuplot.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Stats.cc

    r34 r35  
    2020  Gnuplot Stats::gnuplot_pipe_;
    2121
    22   std::vector<u_int> Stats::accumulated(void) const
     22  std::vector<double> Stats::accumulated(void) const
    2323  {
    2424    std::vector<u_int> sum;
    2525    if (map_.empty())
    26       return sum;
     26      return std::vector<double>();
    2727
    2828    // sum of all users
     
    3131
    3232    // calculate accumulated sum
    33     std::vector<u_int> accum(sum.size());
     33    std::vector<double> accum(sum.size());
    3434    std::partial_sum(sum.begin(),sum.end(),accum.begin());   
    3535    return accum;
    3636  }
    3737
    38   std::vector<u_int> Stats::accumulated(const std::string& user)
     38  std::vector<double> Stats::accumulated(const std::string& user) const
    3939  {
    40     std::vector<u_int> vec=map_[user];
    41     if (vec.empty())
    42       return vec;
    43     std::vector<u_int> accum(vec.size());
     40    if (!map_.count(user))
     41      return std::vector<double>();
     42    std::vector<u_int> vec=(map_.find(user))->second;
     43
     44    std::vector<double> accum(vec.size());
    4445    std::partial_sum(vec.begin(),vec.end(),accum.begin());
    4546    return accum;
     
    6566  {
    6667    char name[]="svnstatXXXXXX";
    67     if (mkstemp(name) == -1) {
     68    if (!strlen(mktemp(name))) {
    6869      std::cerr << "Failed to get unique filename: " << name << std::endl;
    6970      exit(-1);
     
    7273    std::string cmd=std::string("set term png; set output '")+name+".png'";
    7374    gnuplot_pipe_.command(cmd);
    74     cmd="plot sin(x) t 'ddd' w lines";
    75     gnuplot_pipe_.command(cmd);
     75    std::vector<double> x=accumulated();
     76    gnuplot_pipe_.plot_y(x);
     77    for (MapConstIter_ i= map_.begin(); i != map_.end(); i++) {
     78      x=accumulated(i->first);
     79      gnuplot_pipe_.plot_y(x);
     80    }
    7681    return std::string(name)+".png";
    7782  }
Note: See TracChangeset for help on using the changeset viewer.