|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef OPENCV_UTILS_INSTR_HPP |
|
|
#define OPENCV_UTILS_INSTR_HPP |
|
|
|
|
|
#include <opencv2/core/utility.hpp> |
|
|
#include <opencv2/core/utils/tls.hpp> |
|
|
|
|
|
namespace cv { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CV_COLLECT_IMPL_DATA |
|
|
CV_EXPORTS void setImpl(int flags); |
|
|
CV_EXPORTS void addImpl(int flag, const char* func = 0); |
|
|
|
|
|
|
|
|
CV_EXPORTS int getImpl(std::vector<int> &impl, std::vector<String> &funName); |
|
|
|
|
|
CV_EXPORTS bool useCollection(); |
|
|
CV_EXPORTS void setUseCollection(bool flag); |
|
|
|
|
|
#define CV_IMPL_PLAIN 0x01 |
|
|
#define CV_IMPL_OCL 0x02 |
|
|
#define CV_IMPL_IPP 0x04 |
|
|
#define CV_IMPL_MT 0x10 |
|
|
|
|
|
#undef CV_IMPL_ADD |
|
|
#define CV_IMPL_ADD(impl) \ |
|
|
if(cv::useCollection()) \ |
|
|
{ \ |
|
|
cv::addImpl(impl, CV_Func); \ |
|
|
} |
|
|
#endif |
|
|
|
|
|
|
|
|
namespace instr |
|
|
{ |
|
|
|
|
|
#if !defined OPENCV_ABI_CHECK |
|
|
|
|
|
enum TYPE |
|
|
{ |
|
|
TYPE_GENERAL = 0, |
|
|
TYPE_MARKER, |
|
|
TYPE_WRAPPER, |
|
|
TYPE_FUN, |
|
|
}; |
|
|
|
|
|
enum IMPL |
|
|
{ |
|
|
IMPL_PLAIN = 0, |
|
|
IMPL_IPP, |
|
|
IMPL_OPENCL, |
|
|
}; |
|
|
|
|
|
struct NodeDataTls |
|
|
{ |
|
|
NodeDataTls() |
|
|
{ |
|
|
m_ticksTotal = 0; |
|
|
} |
|
|
uint64 m_ticksTotal; |
|
|
}; |
|
|
|
|
|
class CV_EXPORTS NodeData |
|
|
{ |
|
|
public: |
|
|
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); |
|
|
NodeData(NodeData &ref); |
|
|
~NodeData(); |
|
|
NodeData& operator=(const NodeData&); |
|
|
|
|
|
cv::String m_funName; |
|
|
cv::instr::TYPE m_instrType; |
|
|
cv::instr::IMPL m_implType; |
|
|
const char* m_fileName; |
|
|
int m_lineNum; |
|
|
void* m_retAddress; |
|
|
bool m_alwaysExpand; |
|
|
bool m_funError; |
|
|
|
|
|
volatile int m_counter; |
|
|
volatile uint64 m_ticksTotal; |
|
|
TLSDataAccumulator<NodeDataTls> m_tls; |
|
|
int m_threads; |
|
|
|
|
|
|
|
|
double getTotalMs() const { return ((double)m_ticksTotal / cv::getTickFrequency()) * 1000; } |
|
|
double getMeanMs() const { return (((double)m_ticksTotal/m_counter) / cv::getTickFrequency()) * 1000; } |
|
|
}; |
|
|
bool operator==(const NodeData& lhs, const NodeData& rhs); |
|
|
|
|
|
typedef Node<NodeData> InstrNode; |
|
|
|
|
|
CV_EXPORTS InstrNode* getTrace(); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
CV_EXPORTS bool useInstrumentation(); |
|
|
CV_EXPORTS void setUseInstrumentation(bool flag); |
|
|
CV_EXPORTS void resetTrace(); |
|
|
|
|
|
enum FLAGS |
|
|
{ |
|
|
FLAGS_NONE = 0, |
|
|
FLAGS_MAPPING = 0x01, |
|
|
FLAGS_EXPAND_SAME_NAMES = 0x02, |
|
|
}; |
|
|
|
|
|
CV_EXPORTS void setFlags(FLAGS modeFlags); |
|
|
static inline void setFlags(int modeFlags) { setFlags((FLAGS)modeFlags); } |
|
|
CV_EXPORTS FLAGS getFlags(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|