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>
|
|
|
|
|
2012-07-03 22:36:59 +00:00
|
|
|
struct TIME_STATS {
|
2002-04-30 22:22:54 +00:00
|
|
|
bool first;
|
2007-04-11 21:49:57 +00:00
|
|
|
int previous_connected_state;
|
2012-07-03 22:36:59 +00:00
|
|
|
|
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;
|
2012-06-26 20:30:56 +00:00
|
|
|
// the fraction of total time this host runs the client
|
2002-04-30 22:22:54 +00:00
|
|
|
double connected_frac;
|
2012-06-26 20:30:56 +00:00
|
|
|
// of the time this host runs the client,
|
2010-04-01 05:54:29 +00:00
|
|
|
// the fraction it is connected to the Internet,
|
|
|
|
// or -1 if not known
|
2012-06-26 20:30:56 +00:00
|
|
|
double cpu_and_network_available_frac;
|
|
|
|
// of the time this host runs the client,
|
|
|
|
// the fraction it is connected to the Internet
|
|
|
|
// AND network usage is allowed (by prefs and user toggle)
|
|
|
|
// AND CPU usage is allowed
|
2002-04-30 22:22:54 +00:00
|
|
|
double active_frac;
|
2012-06-26 20:30:56 +00:00
|
|
|
// of the time this host runs the 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
|
|
|
|
2012-07-03 22:36:59 +00:00
|
|
|
void init();
|
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
|
|
|
|
2012-04-25 04:10:29 +00:00
|
|
|
double availability_frac(int rsc_type) {
|
|
|
|
double x;
|
|
|
|
if (rsc_type == 0) {
|
|
|
|
x = on_frac*active_frac;
|
|
|
|
} else {
|
|
|
|
x = on_frac*gpu_active_frac;
|
|
|
|
}
|
|
|
|
return x>0?x:1;
|
|
|
|
}
|
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
|