Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
split_statistics.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
24 
25 #ifndef PAGESPEED_KERNEL_BASE_SPLIT_STATISTICS_H_
26 #define PAGESPEED_KERNEL_BASE_SPLIT_STATISTICS_H_
27 
35 
36 namespace net_instaweb {
37 
38 class MessageHandler;
39 class StatisticsLogger;
40 class ThreadSystem;
41 
45  public:
50  virtual ~SplitUpDownCounter();
51  virtual void Set(int64 new_value);
52  virtual int64 SetReturningPreviousValue(int64 new_value);
53  virtual int64 Get() const;
54  virtual StringPiece GetName() const;
55  virtual int64 AddHelper(int64 delta);
56 
57  private:
58  UpDownCounter* rw_;
59  UpDownCounter* w_;
60 
61 };
62 
63 class SplitVariable : public Variable {
64  public:
69  virtual ~SplitVariable();
70  virtual int64 Get() const;
71  virtual StringPiece GetName() const;
72  virtual int64 AddHelper(int64 delta);
73  virtual void Clear();
74 
75  private:
76  Variable* rw_;
77  Variable* w_;
78 
79 };
80 
83 class SplitHistogram : public Histogram {
84  public:
88  SplitHistogram(ThreadSystem* thread_system, Histogram* rw, Histogram* w);
89  virtual ~SplitHistogram();
90 
93  virtual void Add(double value);
94  virtual void Clear();
95  virtual void Render(int index, Writer* writer, MessageHandler* handler);
96  virtual int NumBuckets();
97  virtual void EnableNegativeBuckets();
98  virtual void SetMinValue(double value);
99  virtual void SetMaxValue(double value);
100  virtual void SetSuggestedNumBuckets(int i);
101  virtual double BucketStart(int index);
102  virtual double BucketLimit(int index);
103  virtual double BucketCount(int index);
104 
105  protected:
106  virtual double AverageInternal();
107  virtual double PercentileInternal(const double perc);
108  virtual double StandardDeviationInternal();
109  virtual double CountInternal();
110  virtual double MaximumInternal();
111  virtual double MinimumInternal();
112 
113  virtual AbstractMutex* lock();
114 
115  private:
117  Histogram* rw_;
118  Histogram* w_;
119 
120 
121 };
122 
126  public:
131  virtual ~SplitTimedVariable();
132 
133  virtual void IncBy(int64 delta);
134  virtual int64 Get(int level);
135  virtual void Clear();
136 
137  private:
138  TimedVariable* rw_;
139  TimedVariable* w_;
140 
141 
142 };
143 
145  : public StatisticsTemplate<SplitVariable, SplitUpDownCounter,
146  SplitHistogram, SplitTimedVariable> {
147  public:
157  SplitStatistics(ThreadSystem* thread_system,
158  Statistics* local,
159  Statistics* global);
160 
161  virtual ~SplitStatistics();
162 
166  return local_->console_logger();
167  }
168 
169  protected:
170  virtual SplitUpDownCounter* NewUpDownCounter(StringPiece name);
171  virtual SplitVariable* NewVariable(StringPiece name);
172  virtual SplitUpDownCounter* NewGlobalUpDownCounter(StringPiece name);
173  virtual SplitHistogram* NewHistogram(StringPiece name);
174  virtual SplitTimedVariable* NewTimedVariable(StringPiece name);
175 
176  private:
177  ThreadSystem* thread_system_;
178  scoped_ptr<Statistics> local_;
179  Statistics* global_;
180 
181 };
182 
183 }
184 
185 #endif
virtual StringPiece GetName() const
virtual SplitUpDownCounter * NewGlobalUpDownCounter(StringPiece name)
Default implementation just calls NewUpDownCounter.
virtual int64 Get(int level)
Definition: statistics.h:43
SplitHistogram(ThreadSystem *thread_system, Histogram *rw, Histogram *w)
virtual SplitUpDownCounter * NewUpDownCounter(StringPiece name)
Interface to subclass.
Definition: split_statistics.h:125
virtual void EnableNegativeBuckets()
Allow histogram have negative values.
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
virtual StatisticsLogger * console_logger()
Definition: split_statistics.h:163
Abstract interface for implementing a mutex.
Definition: abstract_mutex.h:28
SplitTimedVariable(TimedVariable *rw, TimedVariable *w)
virtual void Add(double value)
Definition: split_statistics.h:83
Definition: split_statistics.h:44
Definition: split_statistics.h:144
SplitStatistics(ThreadSystem *thread_system, Statistics *local, Statistics *global)
virtual StringPiece GetName() const
virtual void SetSuggestedNumBuckets(int i)
virtual void SetMinValue(double value)
Set the minimum value allowed in histogram.
Definition: scoped_ptr.h:30
virtual double BucketLimit(int index)
Upper bound of a bucket.
virtual int64 AddHelper(int64 delta)
This is virtual so that subclasses can add platform-specific atomicity.
virtual void Clear()
Throw away all data.
virtual int NumBuckets()
Returns number of buckets the histogram actually has.
Definition: split_statistics.h:63
Interface for writing bytes to an output stream.
Definition: writer.h:29
Definition: statistics_template.h:41
Definition: statistics.h:138
virtual SplitVariable * NewVariable(StringPiece name)
Interface to subclass.
SplitVariable(Variable *rw, Variable *w)
virtual void IncBy(int64 delta)
Update the stat value. delta is in milliseconds.
Definition: thread_system.h:40
Definition: statistics.h:73
Definition: message_handler.h:39
SplitUpDownCounter(UpDownCounter *rw, UpDownCounter *w)
virtual double AverageInternal()
Note that these *Internal interfaces require the mutex to be held.
Definition: statistics.h:298
virtual double BucketStart(int index)
virtual double BucketCount(int index)
Value of a bucket.
virtual void SetMaxValue(double value)
virtual int64 AddHelper(int64 delta)
This is virtual so that subclasses can add platform-specific atomicity.
virtual void Clear()
Throw away all data.
virtual int64 SetReturningPreviousValue(int64 new_value)
virtual void Render(int index, Writer *writer, MessageHandler *handler)
Definition: statistics_logger.h:42