metrics.hpp

Go to the documentation of this file.
00001 /* $Id: metrics.hpp 26571 2008-05-12 23:34:38Z suokko $ */
00002 /*
00003    Copyright (C) 2003 - 2008 by David White <dave@whitevine.net>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License version 2
00008    or at your option any later version.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details.
00013 */
00014 
00015 //! @file server/metrics.hpp
00016 //!
00017 
00018 #ifndef METRICS_HPP_INCLUDED
00019 #define METRICS_HPP_INCLUDED
00020 
00021 #include <iosfwd>
00022 
00023 #include <map>
00024 #include <string>
00025 
00026 #include "simple_wml.hpp"
00027 
00028 class metrics
00029 {
00030 public:
00031     metrics();
00032     ~metrics();
00033 
00034     void service_request();
00035     void no_requests();
00036 
00037     void record_sample(const simple_wml::string_span& name,
00038                        clock_t parsing_time, clock_t processing_time);
00039 
00040     void game_terminated(const std::string& reason);
00041 
00042     friend std::ostream& operator<<(std::ostream& out, metrics& met);
00043 
00044     struct sample {
00045         simple_wml::string_span name;
00046         int nsamples;
00047         clock_t parsing_time, processing_time;
00048     };
00049 
00050 private:
00051     std::vector<sample> samples_;
00052 
00053     int most_consecutive_requests_;
00054     int current_requests_;
00055     int nrequests_;
00056     int nrequests_waited_;
00057     const time_t started_at_;
00058     std::map<std::string,int> terminations_;
00059 };
00060 
00061 std::ostream& operator<<(std::ostream& out, metrics& met);
00062 
00063 #endif

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs