Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Stats.cc
r34 r35 20 20 Gnuplot Stats::gnuplot_pipe_; 21 21 22 std::vector< u_int> Stats::accumulated(void) const22 std::vector<double> Stats::accumulated(void) const 23 23 { 24 24 std::vector<u_int> sum; 25 25 if (map_.empty()) 26 return s um;26 return std::vector<double>(); 27 27 28 28 // sum of all users … … 31 31 32 32 // calculate accumulated sum 33 std::vector< u_int> accum(sum.size());33 std::vector<double> accum(sum.size()); 34 34 std::partial_sum(sum.begin(),sum.end(),accum.begin()); 35 35 return accum; 36 36 } 37 37 38 std::vector< u_int> Stats::accumulated(const std::string& user)38 std::vector<double> Stats::accumulated(const std::string& user) const 39 39 { 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()); 44 45 std::partial_sum(vec.begin(),vec.end(),accum.begin()); 45 46 return accum; … … 65 66 { 66 67 char name[]="svnstatXXXXXX"; 67 if ( mkstemp(name) == -1) {68 if (!strlen(mktemp(name))) { 68 69 std::cerr << "Failed to get unique filename: " << name << std::endl; 69 70 exit(-1); … … 72 73 std::string cmd=std::string("set term png; set output '")+name+".png'"; 73 74 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 } 76 81 return std::string(name)+".png"; 77 82 } -
trunk/lib/Stats.h
r34 r35 29 29 void add(const std::string& user, const u_int& revision); 30 30 31 std::string plot(void) const;32 33 31 /// 34 32 /// @bief print statistics … … 46 44 Stats& operator+=(const Stats&); 47 45 46 /// 47 /// Jari, this is public. Naughty! 48 /// 49 /// @todo Make this non-public. The issues that gnuplot is started 50 /// in cwd, but the main program makes a 'chdir' to another, and 51 /// we cannot get gnuplot to change directory if it is 52 /// private. Some redesign is needed. 53 /// 54 static Gnuplot gnuplot_pipe_; 55 48 56 private: 49 57 /// … … 55 63 /// @return accumulated vector of total 56 64 /// 57 std::vector< u_int> accumulated(void) const;65 std::vector<double> accumulated(void) const; 58 66 59 67 /// 60 68 /// @return accumulated vector of stats_[user] 61 69 /// 62 std::vector< u_int> accumulated(const std::string& user);70 std::vector<double> accumulated(const std::string& user) const; 63 71 64 static Gnuplot gnuplot_pipe_; 72 std::string plot(void) const; 73 65 74 // Peter, if the vector is sparse make it a map 66 75 typedef std::map<std::string, std::vector<u_int> > Map_;
Note: See TracChangeset
for help on using the changeset viewer.