Changeset 35 for trunk/lib/Stats.cc
- Timestamp:
- Jan 12, 2006, 5:12:14 PM (17 years ago)
- File:
-
- 1 edited
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 }
Note: See TracChangeset
for help on using the changeset viewer.