EstervQrCode 1.1.1
Library for qr code manipulation
instrumentation.hpp
1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
4 
5 #ifndef OPENCV_UTILS_INSTR_HPP
6 #define OPENCV_UTILS_INSTR_HPP
7 
8 #include <opencv2/core/utility.hpp>
9 #include <opencv2/core/utils/tls.hpp>
10 
11 namespace cv {
12 
15 
16 #ifdef CV_COLLECT_IMPL_DATA
17 CV_EXPORTS void setImpl(int flags); // set implementation flags and reset storage arrays
18 CV_EXPORTS void addImpl(int flag, const char* func = 0); // add implementation and function name to storage arrays
19 // Get stored implementation flags and functions names arrays
20 // Each implementation entry correspond to function name entry, so you can find which implementation was executed in which function
21 CV_EXPORTS int getImpl(std::vector<int> &impl, std::vector<String> &funName);
22 
23 CV_EXPORTS bool useCollection(); // return implementation collection state
24 CV_EXPORTS void setUseCollection(bool flag); // set implementation collection state
25 
26 #define CV_IMPL_PLAIN 0x01 // native CPU OpenCV implementation
27 #define CV_IMPL_OCL 0x02 // OpenCL implementation
28 #define CV_IMPL_IPP 0x04 // IPP implementation
29 #define CV_IMPL_MT 0x10 // multithreaded implementation
30 
31 #undef CV_IMPL_ADD
32 #define CV_IMPL_ADD(impl) \
33  if(cv::useCollection()) \
34  { \
35  cv::addImpl(impl, CV_Func); \
36  }
37 #endif
38 
39 // Instrumentation external interface
40 namespace instr
41 {
42 
43 #if !defined OPENCV_ABI_CHECK
44 
45 enum TYPE
46 {
47  TYPE_GENERAL = 0, // OpenCV API function, e.g. exported function
48  TYPE_MARKER, // Information marker
49  TYPE_WRAPPER, // Wrapper function for implementation
50  TYPE_FUN, // Simple function call
51 };
52 
53 enum IMPL
54 {
58 };
59 
61 {
63  {
64  m_ticksTotal = 0;
65  }
67 };
68 
70 {
71 public:
72  NodeData(const char* funName = 0, const char* fileName = NULL, int lineNum = 0, void* retAddress = NULL, bool alwaysExpand = false, cv::instr::TYPE instrType = TYPE_GENERAL, cv::instr::IMPL implType = IMPL_PLAIN);
76 
80  const char* m_fileName;
81  int m_lineNum;
82  void* m_retAddress;
84  bool m_funError;
85 
86  volatile int m_counter;
87  volatile uint64 m_ticksTotal;
89  int m_threads;
90 
91  // No synchronization
92  double getTotalMs() const { return ((double)m_ticksTotal / cv::getTickFrequency()) * 1000; }
93  double getMeanMs() const { return (((double)m_ticksTotal/m_counter) / cv::getTickFrequency()) * 1000; }
94 };
95 bool operator==(const NodeData& lhs, const NodeData& rhs);
96 
98 
100 
101 #endif // !defined OPENCV_ABI_CHECK
102 
103 
107 
108 enum FLAGS
109 {
113 };
114 
115 CV_EXPORTS void setFlags(FLAGS modeFlags);
116 static inline void setFlags(int modeFlags) { setFlags((FLAGS)modeFlags); }
118 
119 } // namespace instr
120 
122 
123 } // namespace
124 
125 #endif // OPENCV_UTILS_TLS_HPP
Definition: utility.hpp:1075
TLS data accumulator with gathering methods.
Definition: tls.hpp:89
Definition: instrumentation.hpp:70
cv::String m_funName
Definition: instrumentation.hpp:77
const char * m_fileName
Definition: instrumentation.hpp:80
volatile int m_counter
Definition: instrumentation.hpp:86
bool m_alwaysExpand
Definition: instrumentation.hpp:83
double getMeanMs() const
Definition: instrumentation.hpp:93
NodeData(const char *funName=0, const char *fileName=NULL, int lineNum=0, void *retAddress=NULL, bool alwaysExpand=false, cv::instr::TYPE instrType=TYPE_GENERAL, cv::instr::IMPL implType=IMPL_PLAIN)
cv::instr::IMPL m_implType
Definition: instrumentation.hpp:79
NodeData(NodeData &ref)
bool m_funError
Definition: instrumentation.hpp:84
volatile uint64 m_ticksTotal
Definition: instrumentation.hpp:87
TLSDataAccumulator< NodeDataTls > m_tls
Definition: instrumentation.hpp:88
double getTotalMs() const
Definition: instrumentation.hpp:92
void * m_retAddress
Definition: instrumentation.hpp:82
int m_lineNum
Definition: instrumentation.hpp:81
cv::instr::TYPE m_instrType
Definition: instrumentation.hpp:78
int m_threads
Definition: instrumentation.hpp:89
NodeData & operator=(const NodeData &)
InputArrayOfArrays Size InputOutputArray InputOutputArray OutputArrayOfArrays OutputArrayOfArrays OutputArray OutputArray OutputArray int flags
Definition: calib3d.hpp:1617
CvCmpFunc func
Definition: core_c.h:1712
uint64_t uint64
Definition: interface.h:62
#define CV_EXPORTS
Definition: cvdef.h:435
CV_EXPORTS_W double getTickFrequency()
Returns the number of ticks per second.
FLAGS
Definition: instrumentation.hpp:109
@ FLAGS_EXPAND_SAME_NAMES
Definition: instrumentation.hpp:112
@ FLAGS_MAPPING
Definition: instrumentation.hpp:111
@ FLAGS_NONE
Definition: instrumentation.hpp:110
CV_EXPORTS void setFlags(FLAGS modeFlags)
bool operator==(const NodeData &lhs, const NodeData &rhs)
IMPL
Definition: instrumentation.hpp:54
@ IMPL_OPENCL
Definition: instrumentation.hpp:57
@ IMPL_IPP
Definition: instrumentation.hpp:56
@ IMPL_PLAIN
Definition: instrumentation.hpp:55
CV_EXPORTS void resetTrace()
CV_EXPORTS bool useInstrumentation()
TYPE
Definition: instrumentation.hpp:46
@ TYPE_MARKER
Definition: instrumentation.hpp:48
@ TYPE_GENERAL
Definition: instrumentation.hpp:47
@ TYPE_WRAPPER
Definition: instrumentation.hpp:49
@ TYPE_FUN
Definition: instrumentation.hpp:50
CV_EXPORTS void setUseInstrumentation(bool flag)
CV_EXPORTS FLAGS getFlags()
Node< NodeData > InstrNode
Definition: instrumentation.hpp:97
CV_EXPORTS InstrNode * getTrace()
"black box" representation of the file storage associated with a file on disk.
Definition: calib3d.hpp:441
Definition: instrumentation.hpp:61
NodeDataTls()
Definition: instrumentation.hpp:62
uint64 m_ticksTotal
Definition: instrumentation.hpp:66