WordMonitor.h

Go to the documentation of this file.
00001 //
00002 // WordMonitor.h
00003 //
00004 // NAME
00005 // monitoring classes activity.
00006 //
00007 // SYNOPSIS
00008 //
00009 // Only called thru WordContext::Initialize()
00010 //
00011 // DESCRIPTION
00012 // 
00013 // The test directory contains a <i>benchmark-report</i> script used to generate
00014 // and archive graphs from the output of <i>WordMonitor</i>.
00015 //
00016 // CONFIGURATION
00017 //
00018 // wordlist_monitor_period <sec> (default 0)
00019 //   If the value <b>sec</b> is a positive integer, set a timer to
00020 //   print reports every <b>sec</b> seconds. The timer is set using
00021 //   the ALRM signal and will fail if the calling application already
00022 //   has a handler on that signal.
00023 //
00024 // wordlist_monitor_output <file>[,{rrd,readable] (default stderr)
00025 //   Print reports on <b>file</b> instead of the default <b>stderr</b>.
00026 //   If <b>type</b> is set to <b>rrd</b> the output is fit for the
00027 //   <i>benchmark-report</b> script. Otherwise it a (hardly :-) readable
00028 //   string.
00029 //
00030 //
00031 // END
00032 //
00033 // Part of the ht://Dig package   <http://www.htdig.org/>
00034 // Copyright (c) 1999, 2000, 2001 The ht://Dig Group
00035 // For copyright details, see the file COPYING in your distribution
00036 // or the GNU General Public License version 2 or later
00037 // <http://www.gnu.org/copyleft/gpl.html>
00038 //
00039 // $Id: WordMonitor_8h-source.html,v 1.1 2008/06/08 10:13:17 sebdiaz Exp $
00040 //
00041 #ifndef _WordMonitor_h_
00042 #define _WordMonitor_h_
00043 
00044 #include <stdio.h>
00045 #if TIME_WITH_SYS_TIME
00046 #include <sys/time.h>
00047 #include <time.h>
00048 #else
00049 # if HAVE_SYS_TIME_H
00050 #  include <sys/time.h>
00051 # else
00052 #  include <time.h>
00053 # endif
00054 #endif
00055 
00056 #define WORD_MONITOR_WRITE                      1
00057 #define WORD_MONITOR_READ                       2
00058 #define WORD_MONITOR_COMPRESS_01                3
00059 #define WORD_MONITOR_COMPRESS_02                4
00060 #define WORD_MONITOR_COMPRESS_03                5
00061 #define WORD_MONITOR_COMPRESS_04                6
00062 #define WORD_MONITOR_COMPRESS_05                7
00063 #define WORD_MONITOR_COMPRESS_06                8
00064 #define WORD_MONITOR_COMPRESS_07                9
00065 #define WORD_MONITOR_COMPRESS_08               10
00066 #define WORD_MONITOR_COMPRESS_09               11
00067 #define WORD_MONITOR_COMPRESS_10               12
00068 #define WORD_MONITOR_COMPRESS_MORE             13
00069 #define WORD_MONITOR_PAGE_IBTREE               14
00070 #define WORD_MONITOR_PAGE_LBTREE               15
00071 #define WORD_MONITOR_PAGE_UNKNOWN              16
00072 #define WORD_MONITOR_PUT                       17
00073 #define WORD_MONITOR_GET                       18
00074 #define WORD_MONITOR_GET_NEXT                  19
00075 #define WORD_MONITOR_GET_SET_RANGE             20
00076 #define WORD_MONITOR_GET_OTHER                 21
00077 #define WORD_MONITOR_LEVEL                     22
00078 #define WORD_MONITOR_PGNO                      23
00079 #define WORD_MONITOR_CMP                       24
00080 
00081 #define WORD_MONITOR_VALUES_SIZE               50
00082 
00083 #ifdef __cplusplus
00084 extern "C" {
00085 #endif
00086 
00087   void word_monitor_click(void *monitor);
00088   void word_monitor_add(void *monitor, int index, unsigned int value);
00089   void word_monitor_set(void *monitor, int index, unsigned int value);
00090   unsigned int word_monitor_get(void *monitor, int index);
00091 
00092 #ifdef __cplusplus
00093 }
00094 #endif
00095 
00096 #ifdef __cplusplus
00097 
00098 #include "Configuration.h"
00099 #include "htString.h"
00100 
00101 class WordMonitor {
00102  public:
00103     WordMonitor(const Configuration &config);
00104     ~WordMonitor();
00105 
00106     void Add(int index, unsigned int value) { values[index] += value; Click(); }
00107     void Set(int index, unsigned int value) { values[index] = value; Click(); }
00108     unsigned int Get(int index) { return values[index]; }
00109 
00110     const String Report() const;
00111 
00112     void Start();
00113     void Click();
00114     void Stop();
00115 
00116  private:
00117     unsigned int values[WORD_MONITOR_VALUES_SIZE];
00118     unsigned int old_values[WORD_MONITOR_VALUES_SIZE];
00119     time_t started;
00120     time_t elapsed;
00121     int period;
00122     FILE* output;
00123     int output_style;
00124     static char* values_names[WORD_MONITOR_VALUES_SIZE];
00125 };
00126 
00127 #endif /* __cplusplus */
00128 
00129 #endif /* _WordMonitor_h_ */
00130 

Generated on Sun Jun 8 10:56:40 2008 for GNUmifluz by  doxygen 1.5.5