xerus
a general purpose tensor library
performanceAnalysis.h
Go to the documentation of this file.
1 // Xerus - A General Purpose Tensor Library
2 // Copyright (C) 2014-2017 Benjamin Huber and Sebastian Wolf.
3 //
4 // Xerus is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as published
6 // by the Free Software Foundation, either version 3 of the License,
7 // or (at your option) any later version.
8 //
9 // Xerus is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
13 //
14 // You should have received a copy of the GNU Affero General Public License
15 // along with Xerus. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // For further information on Xerus visit https://libXerus.org
18 // or contact us at contact@libXerus.org.
19 
25 #pragma once
26 
27 #include "standard.h"
28 #include <string>
29 
30 #ifdef XERUS_PERFORMANCE_ANALYSIS
31  #include <map>
32  #include <utility>
33  #include "timeMeasure.h"
34  #define XERUS_PA_START const size_t pa_startTime = misc::uTime()
35  #define XERUS_PA_END(group, name, parameter) { std::pair<size_t, size_t>& pa_call = xerus::misc::performanceAnalysis::calls[group][name][parameter]; pa_call.first++; pa_call.second += misc::uTime() - pa_startTime; }
36 #else
37  #define XERUS_PA_START
38  #define XERUS_PA_END(group, name, parameter)
39 #endif
40 
41 namespace xerus {
42  namespace misc {
44  namespace performanceAnalysis {
45  #ifdef XERUS_PERFORMANCE_ANALYSIS
46  extern const size_t startupTime;
47  extern std::map<std::string, std::map<std::string, std::map<std::string, std::pair<size_t, size_t>>>> calls;
48  #endif
49 
51  std::string get_analysis();
52  }
53  }
54 }
55 
56 
The main namespace of xerus.
Definition: basic.h:37
std::string get_analysis()
Returns a detailed performance analysis if XERUS_PERFORMANCE_ANALYSIS is set, an emtpy string otherwi...
Header file for basic time measurement functionality.
Header file for global shorthand notations of elementary integer types and attribute lists...