Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
101be77d
O
Opencv
项目概览
Greenplum
/
Opencv
12 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
101be77d
编写于
11月 22, 2021
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21092 from alalek:core_logger_show_timestamp
上级
93b6e80c
61f1ee2d
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
74 addition
and
18 deletion
+74
-18
modules/core/src/logger.cpp
modules/core/src/logger.cpp
+21
-5
modules/core/src/precomp.hpp
modules/core/src/precomp.hpp
+4
-0
modules/core/src/system.cpp
modules/core/src/system.cpp
+45
-0
modules/core/src/trace.cpp
modules/core/src/trace.cpp
+4
-13
未找到文件。
modules/core/src/logger.cpp
浏览文件 @
101be77d
...
...
@@ -71,17 +71,33 @@ LogLevel getLogLevel()
namespace
internal
{
static
int
getShowTimestampMode
()
{
static
bool
param_timestamp_enable
=
utils
::
getConfigurationParameterBool
(
"OPENCV_LOG_TIMESTAMP"
,
true
);
static
bool
param_timestamp_ns_enable
=
utils
::
getConfigurationParameterBool
(
"OPENCV_LOG_TIMESTAMP_NS"
,
false
);
return
(
param_timestamp_enable
?
1
:
0
)
+
(
param_timestamp_ns_enable
?
2
:
0
);
}
void
writeLogMessage
(
LogLevel
logLevel
,
const
char
*
message
)
{
const
int
threadID
=
cv
::
utils
::
getThreadID
();
std
::
string
message_id
;
switch
(
getShowTimestampMode
())
{
case
1
:
message_id
=
cv
::
format
(
"%d@%0.3f"
,
threadID
,
getTimestampNS
()
*
1e-9
);
break
;
case
1
+
2
:
message_id
=
cv
::
format
(
"%d@%llu"
,
threadID
,
getTimestampNS
());
break
;
default:
message_id
=
cv
::
format
(
"%d"
,
threadID
);
break
;
}
std
::
ostringstream
ss
;
switch
(
logLevel
)
{
case
LOG_LEVEL_FATAL
:
ss
<<
"[FATAL:"
<<
threadID
<<
"] "
<<
message
<<
std
::
endl
;
break
;
case
LOG_LEVEL_ERROR
:
ss
<<
"[ERROR:"
<<
threadID
<<
"] "
<<
message
<<
std
::
endl
;
break
;
case
LOG_LEVEL_WARNING
:
ss
<<
"[ WARN:"
<<
threadID
<<
"] "
<<
message
<<
std
::
endl
;
break
;
case
LOG_LEVEL_INFO
:
ss
<<
"[ INFO:"
<<
threadID
<<
"] "
<<
message
<<
std
::
endl
;
break
;
case
LOG_LEVEL_DEBUG
:
ss
<<
"[DEBUG:"
<<
threadID
<<
"] "
<<
message
<<
std
::
endl
;
break
;
case
LOG_LEVEL_FATAL
:
ss
<<
"[FATAL:"
<<
message_id
<<
"] "
<<
message
<<
std
::
endl
;
break
;
case
LOG_LEVEL_ERROR
:
ss
<<
"[ERROR:"
<<
message_id
<<
"] "
<<
message
<<
std
::
endl
;
break
;
case
LOG_LEVEL_WARNING
:
ss
<<
"[ WARN:"
<<
message_id
<<
"] "
<<
message
<<
std
::
endl
;
break
;
case
LOG_LEVEL_INFO
:
ss
<<
"[ INFO:"
<<
message_id
<<
"] "
<<
message
<<
std
::
endl
;
break
;
case
LOG_LEVEL_DEBUG
:
ss
<<
"[DEBUG:"
<<
message_id
<<
"] "
<<
message
<<
std
::
endl
;
break
;
case
LOG_LEVEL_VERBOSE
:
ss
<<
message
<<
std
::
endl
;
break
;
case
LOG_LEVEL_SILENT
:
return
;
// avoid compiler warning about incomplete switch
case
ENUM_LOG_LEVEL_FORCE_INT
:
return
;
// avoid compiler warning about incomplete switch
...
...
modules/core/src/precomp.hpp
浏览文件 @
101be77d
...
...
@@ -374,6 +374,10 @@ bool __termination; // skip some cleanups, because process is terminating
cv
::
Mutex
&
getInitializationMutex
();
/// @brief Returns timestamp in nanoseconds since program launch
int64
getTimestampNS
();
// TODO Memory barriers?
#define CV_SINGLETON_LAZY_INIT_(TYPE, INITIALIZER, RET_VALUE) \
static TYPE* volatile instance = NULL; \
...
...
modules/core/src/system.cpp
浏览文件 @
101be77d
...
...
@@ -934,6 +934,51 @@ int64 getCPUTickCount(void)
#endif
namespace
internal
{
class
Timestamp
{
public:
const
int64
zeroTickCount
;
const
double
ns_in_ticks
;
Timestamp
()
:
zeroTickCount
(
getTickCount
())
,
ns_in_ticks
(
1e9
/
getTickFrequency
())
{
// nothing
}
int64
getTimestamp
()
{
int64
t
=
getTickCount
();
return
(
int64
)((
t
-
zeroTickCount
)
*
ns_in_ticks
);
}
static
Timestamp
&
getInstance
()
{
static
Timestamp
g_timestamp
;
return
g_timestamp
;
}
};
class
InitTimestamp
{
public:
InitTimestamp
()
{
Timestamp
::
getInstance
();
}
};
static
InitTimestamp
g_initialize_timestamp
;
// force zero timestamp initialization
}
// namespace
int64
getTimestampNS
()
{
return
internal
::
Timestamp
::
getInstance
().
getTimestamp
();
}
const
String
&
getBuildInformation
()
{
static
String
build_info
=
...
...
modules/core/src/trace.cpp
浏览文件 @
101be77d
...
...
@@ -63,15 +63,6 @@ namespace details {
#pragma warning(disable:4065) // switch statement contains 'default' but no 'case' labels
#endif
static
int64
g_zero_timestamp
=
0
;
static
int64
getTimestamp
()
{
int64
t
=
getTickCount
();
static
double
tick_to_ns
=
1e9
/
getTickFrequency
();
return
(
int64
)((
t
-
g_zero_timestamp
)
*
tick_to_ns
);
}
static
bool
getParameterTraceEnable
()
{
static
bool
param_traceEnable
=
utils
::
getConfigurationParameterBool
(
"OPENCV_TRACE"
,
false
);
...
...
@@ -485,7 +476,7 @@ Region::Region(const LocationStaticStorage& location) :
}
}
int64
beginTimestamp
=
getTimestamp
();
int64
beginTimestamp
=
getTimestamp
NS
();
int
currentDepth
=
ctx
.
getCurrentDepth
()
+
1
;
switch
(
location
.
flags
&
REGION_FLAG_IMPL_MASK
)
...
...
@@ -635,7 +626,7 @@ void Region::destroy()
}
}
int64
endTimestamp
=
getTimestamp
();
int64
endTimestamp
=
getTimestamp
NS
();
int64
duration
=
endTimestamp
-
ctx
.
stackTopBeginTimestamp
();
bool
active
=
isActive
();
...
...
@@ -844,7 +835,7 @@ static bool isInitialized = false;
TraceManager
::
TraceManager
()
{
g_zero_timestamp
=
cv
::
getTickCount
();
(
void
)
cv
::
getTimestampNS
();
isInitialized
=
true
;
CV_LOG
(
"TraceManager ctor: "
<<
(
void
*
)
this
);
...
...
@@ -990,7 +981,7 @@ void parallelForFinalize(const Region& rootRegion)
{
TraceManagerThreadLocal
&
ctx
=
getTraceManager
().
tls
.
getRef
();
int64
endTimestamp
=
getTimestamp
();
int64
endTimestamp
=
getTimestamp
NS
();
int64
duration
=
endTimestamp
-
ctx
.
stackTopBeginTimestamp
();
CV_LOG_PARALLEL
(
NULL
,
"parallel_for duration: "
<<
duration
<<
" "
<<
&
rootRegion
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录