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
|
|
|
|
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 {
|
2005-01-28 20:03:57 +00:00
|
|
|
double last_update;
|
2002-04-30 22:22:54 +00:00
|
|
|
bool first;
|
2007-04-11 21:49:57 +00:00
|
|
|
int previous_connected_state;
|
2002-04-30 22:22:54 +00:00
|
|
|
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,
|
2005-01-28 21:53:09 +00:00
|
|
|
// the fraction it is connected to the Internet,
|
|
|
|
// or -1 if not known
|
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
|
2005-01-28 21:53:09 +00:00
|
|
|
// (as determined by preferences, manual suspend/resume, etc.)
|
2005-06-13 16:51:14 +00:00
|
|
|
double cpu_efficiency;
|
|
|
|
// The ratio between CPU time accumulated by BOINC apps
|
|
|
|
// and the wall time those apps are scheduled at the OS level.
|
|
|
|
// May be less than one if
|
|
|
|
// 1) apps page or do I/O
|
|
|
|
// 2) other CPU-intensive apps run
|
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;
|
|
|
|
|
2007-04-11 21:49:57 +00:00
|
|
|
void update(int suspend_reason);
|
2005-06-13 16:51:14 +00:00
|
|
|
void update_cpu_efficiency(double cpu_wall_time, double cpu_time);
|
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&);
|
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&);
|
|
|
|
void quit();
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
2005-06-07 19:22:50 +00:00
|
|
|
|
|
|
|
#endif
|