43 most_consecutive_requests_(0),
47 started_at_(time(nullptr)),
57 delete[]
itor->name.begin();
81 clock_t parsing_time, clock_t processing_time)
85 || isample->name !=
name) {
93 new_sample.
name = dup_name;
94 samples_.insert(isample, new_sample);
100 isample->parsing_time += parsing_time;
101 isample->processing_time += processing_time;
102 isample->max_parsing_time = std::max(parsing_time,isample->max_parsing_time);
103 isample->max_processing_time = std::max(processing_time,isample->max_processing_time);
113 if (
terminations_.empty())
return out <<
"No game ended so far.";
116 out <<
"Games have been terminated in the following ways:\n";
118 out <<
i->first <<
": " <<
i->second <<
"\n";
121 out <<
"Total number of games = " <<
n;
130 std::vector<metrics::sample> ordered_samples =
samples_;
133 out <<
"\nSampled request types:\n";
138 for(std::vector<metrics::sample>::const_iterator
s = ordered_samples.begin();
s != ordered_samples.end(); ++
s) {
139 out <<
"'" <<
s->name <<
"' called " <<
s->nsamples <<
" times "
140 <<
s->parsing_time <<
"("<<
s->max_parsing_time <<
") parsing time, "
141 <<
s->processing_time <<
"("<<
s->max_processing_time<<
") processing time\n";
143 pa +=
s->parsing_time;
144 pr +=
s->processing_time;
146 out <<
"Total number of request samples = " << n <<
"\n"
147 <<
"Total parsing time = " << pa <<
"\n"
148 <<
"Total processing time = " << pr;
155 const time_t time_up = time(
nullptr) - met.
started_at_;
156 const int seconds = time_up%60;
157 const int minutes = (time_up/60)%60;
158 const int hours = (time_up/(60*60))%24;
159 const int days = time_up/(60*60*24);
161 const int percent_immediate = (requests_immediate*100)/(met.
nrequests_ > 0 ? met.
nrequests_ : 1);
162 out <<
"METRICS\nUp " << days <<
" days, " << hours <<
" hours, "
163 << minutes <<
" minutes, " << seconds <<
" seconds\n"
164 << met.
nrequests_ <<
" requests serviced. " << requests_immediate
165 <<
" (" << percent_immediate <<
"%) "
166 <<
"requests were serviced immediately.\n"
std::ostream & games(std::ostream &out) const
static paths::dest_vect::iterator lower_bound(paths::dest_vect &v, const map_location &loc)
GLdouble GLdouble GLdouble b
std::ostream & requests(std::ostream &out) const
std::vector< sample > samples_
bool operator()(const metrics::sample &a, const metrics::sample &b) const
GLboolean GLboolean GLboolean GLboolean a
simple_wml::string_span name
void game_terminated(const std::string &reason)
std::map< std::string, tfilter >::iterator itor
std::ostream & operator<<(std::ostream &out, metrics &met)
static int sort(lua_State *L)
GLuint const GLchar * name
std::map< std::string, int > terminations_
int most_consecutive_requests_
bool operator()(const simple_wml::string_span &a, const simple_wml::string_span &b)
void record_sample(const simple_wml::string_span &name, clock_t parsing_time, clock_t processing_time)
GLsizei const GLcharARB ** string