Changeset 74 for trunk/lib/Stats.cc
 Timestamp:
 Mar 7, 2006, 4:46:59 PM (16 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/lib/Stats.cc
r73 r74 24 24 u_int Stats::latest_revision_=0; 25 25 26 std::vector< double> Stats::accumulated(void) const26 std::vector<u_int> Stats::accumulated(void) const 27 27 { 28 28 // sum of all users … … 32 32 33 33 // calculate accumulated sum 34 std::vector< double> accum(sum.size());34 std::vector<u_int> accum(sum.size()); 35 35 std::partial_sum(sum.begin(),sum.end(),accum.begin()); 36 36 assert(sum.size()==accum.size()); … … 38 38 } 39 39 40 std::vector< double> Stats::accumulated(const std::string& user) const40 std::vector<u_int> Stats::accumulated(const std::string& user) const 41 41 { 42 42 if (!map_.count(user)) 43 return std::vector< double>();43 return std::vector<u_int>(); 44 44 std::vector<u_int> vec=(map_.find(user))>second; 45 45 … … 47 47 vec.insert(vec.end(), latest_revision_+1vec.size(), 0); 48 48 49 std::vector< double> accum(vec.size());49 std::vector<u_int> accum(vec.size()); 50 50 std::partial_sum(vec.begin(),vec.end(),accum.begin()); 51 51 return accum; … … 109 109 gp>command("set key left Left reverse"); 110 110 gp>command("set multiplot"); 111 std::vector< double> x=accumulated();111 std::vector<u_int> x=accumulated(); 112 112 std::stringstream sa; 113 113 sa << x.back() << " total"; 114 double yrange_max=1.03*x.back()+1; 115 gp>yrange(yrange_max); 114 116 gp>linetitle(sa.str()); 115 117 gp>linestyle("steps 1"); 116 118 gp>plot(x); 117 size_t plotno= 2;119 size_t plotno=1; 118 120 for (MapConstIter_ i= map_.begin(); i != map_.end(); i++) { 119 121 std::stringstream s0; 120 s0 << "set key height " << plotno;122 s0 << "set key height " << 2*plotno; 121 123 gp>command(s0.str()); 122 124 x=accumulated(i>first); 123 125 std::stringstream s; 124 126 s << x.back() << " " << i>first; 127 gp>yrange(yrange_max); 125 128 gp>linetitle(s.str()); 126 129 // Jari, reuse the stream above 127 130 std::stringstream s2; 128 s2 << "steps " << plotno++;131 s2 << "steps " << ++plotno; 129 132 gp>linestyle(s2.str()); 130 133 gp>plot(x); 131 134 } 132 135 gp>command("unset multiplot"); 136 gp>yrange(); 133 137 134 138 return name;
Note: See TracChangeset
for help on using the changeset viewer.