00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
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
00128
00129 #endif
00130