tjprofiler.h
1 /***************************************************************************
2  tjprofiler.h - description
3  -------------------
4  begin : Mon Aug 5 2002
5  copyright : (C) 2000-2015 by Thies H. Jochimsen
6  email : thies@jochimsen.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef TJPROFILER_H
19 #define TJPROFILER_H
20 
21 
22 #include <tjutils/tjutils.h>
23 #include <tjutils/tjstatic.h>
24 #include <tjutils/tjlabel.h>
25 #include <tjutils/tjhandler.h>
26 
41 class Profiler : public StaticHandler<Profiler> {
42 
43  public:
44 
45  Profiler(const STD_string& func_name);
46  ~Profiler();
47 
51  static void reset();
52 
56  static void dump_final_result();
57 
61  static STD_string get_memory_usage();
62 
63 
64  // functions to initialize/delete static members by the StaticHandler template class
65  static void init_static();
66  static void destroy_static();
67 
68 
69  // for debugging List
70  static const char* get_compName();
71 
72 
73  private:
74 
75  STD_string func_label;
76  double starttime;
77 
78  struct elapsed {
79  elapsed() : time_spent(0.0) {}
80  double time_spent;
81  };
82 
83  struct FuncMap : public STD_map<STD_string, elapsed>, public Labeled {};
84 
85  static SingletonHandler<FuncMap, true> func_map;
86 };
87 
90 #endif
static void reset()
static STD_string get_memory_usage()
static void dump_final_result()