2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2002-04-30 22:22:54 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This 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 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "miofile.h"
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
class TIME_STATS {
|
2005-01-28 20:03:57 +00:00
|
|
|
double last_update;
|
2002-04-30 22:22:54 +00:00
|
|
|
bool first;
|
|
|
|
public:
|
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;
|
2004-10-14 22:01:05 +00:00
|
|
|
// the fraction of total time this host runs the core client
|
2002-04-30 22:22:54 +00:00
|
|
|
double connected_frac;
|
2005-01-28 19:01:08 +00:00
|
|
|
// of the time this host runs the core client,
|
|
|
|
// the fraction it is connected to the Internet
|
2002-04-30 22:22:54 +00:00
|
|
|
double active_frac;
|
2005-01-28 19:01:08 +00:00
|
|
|
// of the time this host runs the core client,
|
|
|
|
// the fraction it is enabled to work
|
2004-10-01 22:00:39 +00:00
|
|
|
// (due to preferences, manual suspend/resume, etc.)
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2005-01-28 21:46:41 +00:00
|
|
|
void update(double now, int connected_state, bool is_active);
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
TIME_STATS();
|
2004-06-12 04:45:36 +00:00
|
|
|
int write(MIOFILE&, bool to_server);
|
|
|
|
int parse(MIOFILE&);
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|