2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-01-20 23:22:22 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2002-04-30 22:22:54 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2005-01-20 23:22:22 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-01-20 23:22:22 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2005-06-07 19:22:50 +00:00
|
|
|
#ifndef _TIME_STATS_
|
|
|
|
#define _TIME_STATS_
|
|
|
|
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "miofile.h"
|
2006-07-10 04:09:55 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
class TIME_STATS {
|
|
|
|
bool first;
|
2007-04-11 21:49:57 +00:00
|
|
|
int previous_connected_state;
|
2002-04-30 22:22:54 +00:00
|
|
|
public:
|
2008-05-28 19:15:44 +00:00
|
|
|
double last_update;
|
2004-10-01 22:00:39 +00:00
|
|
|
// we maintain an exponentially weighted average of these quantities:
|
2002-04-30 22:22:54 +00:00
|
|
|
double on_frac;
|
2010-04-01 05:54:29 +00:00
|
|
|
// the fraction of total time this host runs the core client
|
2002-04-30 22:22:54 +00:00
|
|
|
double connected_frac;
|
2010-04-01 05:54:29 +00:00
|
|
|
// of the time this host runs the core client,
|
|
|
|
// the fraction it is connected to the Internet,
|
|
|
|
// or -1 if not known
|
2002-04-30 22:22:54 +00:00
|
|
|
double active_frac;
|
2010-04-01 05:54:29 +00:00
|
|
|
// of the time this host runs the core client,
|
2010-08-23 05:00:22 +00:00
|
|
|
// the fraction it is enabled to use CPU
|
2010-04-01 05:54:29 +00:00
|
|
|
// (as determined by preferences, manual suspend/resume, etc.)
|
2010-08-23 05:00:22 +00:00
|
|
|
double gpu_active_frac;
|
|
|
|
// same, GPU
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2007-04-11 21:49:57 +00:00
|
|
|
FILE* time_stats_log;
|
2006-07-10 04:09:55 +00:00
|
|
|
double inactive_start;
|
|
|
|
|
2010-08-23 05:00:22 +00:00
|
|
|
void update(int suspend_reason, int gpu_suspend_reason);
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
TIME_STATS();
|
2004-06-12 04:45:36 +00:00
|
|
|
int write(MIOFILE&, bool to_server);
|
2011-08-09 21:44:14 +00:00
|
|
|
int parse(XML_PARSER&);
|
2006-07-10 04:09:55 +00:00
|
|
|
|
2007-04-11 21:49:57 +00:00
|
|
|
void log_append(const char*, double);
|
|
|
|
void log_append_net(int);
|
|
|
|
void trim_stats_log();
|
|
|
|
void get_log_after(double, MIOFILE&);
|
2007-12-02 15:57:08 +00:00
|
|
|
void start();
|
2007-04-11 21:49:57 +00:00
|
|
|
void quit();
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
2005-06-07 19:22:50 +00:00
|
|
|
|
|
|
|
#endif
|