00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef GEOS_PROFILER_H
00017 #define GEOS_PROFILER_H
00018
00019 #include <memory>
00020 #include <vector>
00021 #include <map>
00022 #include <iostream>
00023 #include <string>
00024 #ifndef _MSC_VER
00025 # include <sys/time.h>
00026 #endif
00027 #include <geos/timeval.h>
00028
00029 #ifndef PROFILE
00030 #define PROFILE 0
00031 #endif
00032
00033 using namespace std;
00034
00035 namespace geos {
00036
00037
00038
00039
00040
00041
00042
00043 class Profile {
00044 public:
00046 Profile(string name);
00047
00049 ~Profile();
00050
00052 void start();
00053
00055 void stop();
00056
00058 double getMax() const;
00059
00061 double getMin() const;
00062
00064 double getTot() const;
00065
00067 double getAvg() const;
00068
00070 unsigned int getNumTimings() const;
00071
00073 string name;
00074
00075
00076 private:
00077
00078
00079 struct timeval starttime, stoptime;
00080
00081
00082 vector<double> timings;
00083
00084
00085 double totaltime;
00086
00087
00088 double max;
00089
00090
00091 double min;
00092
00093
00094 double avg;
00095
00096 };
00097
00098
00099
00100
00101
00102
00103
00104 class Profiler {
00105
00106 public:
00107
00108 Profiler();
00109 ~Profiler();
00110
00116 static Profiler *instance(void);
00117
00123 void start(string name);
00124
00130 void stop(string name);
00131
00133 Profile *get(string name);
00134
00135 map<string, Profile *> profs;
00136 };
00137
00138
00140 ostream& operator<< (ostream& os, const Profile&);
00141
00143 ostream& operator<< (ostream& os, const Profiler&);
00144
00145 }
00146 #endif // ndef GEOS_PROFILER_H
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164