00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef TJPROFILER_H
00019 #define TJPROFILER_H
00020
00021
00022 #include <tjutils/tjutils.h>
00023 #include <tjutils/tjstatic.h>
00024 #include <tjutils/tjlabel.h>
00025 #include <tjutils/tjhandler.h>
00026
00041 class Profiler : public StaticHandler<Profiler> {
00042
00043 public:
00044
00045 Profiler(const STD_string& func_name);
00046 ~Profiler();
00047
00051 static void reset();
00052
00056 static void dump_final_result();
00057
00061 static STD_string get_memory_usage();
00062
00063
00064
00065 static void init_static();
00066 static void destroy_static();
00067
00068
00069
00070 static const char* get_compName();
00071
00072
00073 private:
00074
00075 STD_string func_label;
00076 double starttime;
00077
00078 struct elapsed {
00079 elapsed() : time_spent(0.0) {}
00080 double time_spent;
00081 };
00082
00083 struct FuncMap : public STD_map<STD_string, elapsed>, public Labeled {};
00084
00085 static SingletonHandler<FuncMap, true> func_map;
00086 };
00087
00090 #endif