ManaPlus
perfomance.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2012-2017 The ManaPlus Developers
4  *
5  * This file is part of The ManaPlus Client.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef UTILS_PERFOMANCE_H
22 #define UTILS_PERFOMANCE_H
23 
24 #ifdef USE_PROFILER
25 #include "utils/vector.h"
26 
27 #include <string>
28 #include <sstream>
29 #include <list>
30 #include <set>
31 
32 #include "localconsts.h"
33 
34 #define PROFILER_START() Perfomance::start();
35 #define PROFILER_END() Perfomance::flush();
36 #define BLOCK_START(name) Perfomance::blockStart(name);
37 #define BLOCK_END(name) Perfomance::blockEnd(name);
38 #define FUNC_BLOCK(name, id) Perfomance::Func PerfomanceFunc##id(name);
39 
40 namespace Perfomance
41 {
42  void start();
43 
44  void init(const std::string &path);
45 
46  void clear();
47 
48  void blockStart(const std::string &name);
49 
50  void blockEnd(const std::string &name);
51 
52  void flush();
53 
54  class Func final
55  {
56  public:
57  explicit Func(const std::string &str) :
58  name(str)
59  {
60  blockStart(str);
61  }
62 
63  A_DELETE_COPY(Func)
64 
65  ~Func()
66  {
67  blockEnd(name);
68  }
69 
70  std::string name;
71  };
72 } // namespace Perfomance
73 
74 #else // USE_PROFILER
75 
76 #define PROFILER_START()
77 #define PROFILER_END()
78 #define BLOCK_START(name)
79 #define BLOCK_END(name)
80 #define FUNC_BLOCK(name, id)
81 
82 #endif // USE_PROFILER
83 #endif // UTILS_PERFOMANCE_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
void init()
Definition: playerinfo.cpp:446
#define final
Definition: localconsts.h:45
void clear()
Definition: playerinfo.cpp:464