Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
b6dd80f8
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b6dd80f8
编写于
4月 16, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
4月 16, 2020
浏览文件
操作
浏览文件
下载
差异文件
!285 Dump the perf data by executed sequence, not alphabetic.
Merge pull request !285 from ZhangQinghua/master
上级
7d406e8e
0b75e289
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
6 deletion
+20
-6
mindspore/ccsrc/utils/profile.cc
mindspore/ccsrc/utils/profile.cc
+18
-5
mindspore/ccsrc/utils/profile.h
mindspore/ccsrc/utils/profile.h
+2
-1
未找到文件。
mindspore/ccsrc/utils/profile.cc
浏览文件 @
b6dd80f8
...
...
@@ -30,6 +30,7 @@
namespace
mindspore
{
namespace
{
constexpr
size_t
TIME_INFO_PREFIX_NUM_LEN
=
4
;
const
char
KEY_PROF_TOTAL
[]
=
"__total__"
;
void
PrintProfile
(
std
::
ostringstream
&
oss
,
const
TimeInfo
&
time_info
,
int
indent
=
0
,
...
...
@@ -42,15 +43,16 @@ void PrintTimeInfoMap(std::ostringstream& oss, const TimeInfoMap& dict, int inde
continue
;
}
// indent by multiples of 4 spaces.
auto
name
=
iter
->
first
.
substr
(
TIME_INFO_PREFIX_NUM_LEN
);
oss
<<
std
::
setw
(
indent
*
4
)
<<
""
<<
"["
<<
iter
->
first
<<
"]: "
<<
iter
->
second
->
time_
;
<<
"["
<<
name
<<
"]: "
<<
iter
->
second
->
time_
;
if
(
iter
->
second
->
dict_
!=
nullptr
)
{
oss
<<
", ["
<<
iter
->
second
->
dict_
->
size
()
<<
"]"
;
}
oss
<<
"
\n
"
;
std
::
string
newPrefix
=
prefix
;
if
(
iter
->
first
.
find
(
"Cycle "
)
!=
0
)
{
if
(
iter
->
first
.
find
(
"Cycle "
)
==
std
::
string
::
npos
)
{
newPrefix
=
prefix
.
empty
()
?
iter
->
first
:
prefix
+
"."
+
iter
->
first
;
}
PrintProfile
(
oss
,
*
iter
->
second
,
indent
+
1
,
sums
,
newPrefix
);
...
...
@@ -94,7 +96,14 @@ void PrintProfile(std::ostringstream& oss, const TimeInfo& time_info, int indent
oss
<<
"Sums
\n
"
;
if
(
total
>=
0.0
+
DBL_EPSILON
)
{
for
(
auto
&
iter
:
*
sums
)
{
oss
<<
" "
<<
std
::
left
<<
std
::
setw
(
36
)
<<
iter
.
first
<<
" : "
<<
std
::
right
<<
std
::
setw
(
12
)
<<
std
::
fixed
std
::
string
name
=
iter
.
first
;
name
.
erase
(
0
,
TIME_INFO_PREFIX_NUM_LEN
);
std
::
size_t
pos
=
0
;
while
((
pos
=
name
.
find
(
'.'
,
pos
))
!=
std
::
string
::
npos
)
{
pos
++
;
name
.
erase
(
pos
,
TIME_INFO_PREFIX_NUM_LEN
);
}
oss
<<
" "
<<
std
::
left
<<
std
::
setw
(
36
)
<<
name
<<
" : "
<<
std
::
right
<<
std
::
setw
(
12
)
<<
std
::
fixed
<<
std
::
setprecision
(
6
)
<<
iter
.
second
<<
"s : "
<<
std
::
right
<<
std
::
setw
(
5
)
<<
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
iter
.
second
/
total
*
100
<<
"%
\n
"
;
}
...
...
@@ -241,14 +250,18 @@ void ProfContext::Insert(const std::string& name, const TimeInfo* time) noexcept
}
}
auto
iter
=
time_info_
->
dict_
->
find
(
name
);
std
::
stringstream
ss
;
ss
<<
std
::
setw
(
TIME_INFO_PREFIX_NUM_LEN
)
<<
std
::
setfill
(
'0'
)
<<
time_info_
->
actionNum_
;
std
::
string
sorted_name
(
ss
.
str
()
+
name
);
time_info_
->
actionNum_
++
;
auto
iter
=
time_info_
->
dict_
->
find
(
sorted_name
);
// if contains item with same name, delete it
if
(
iter
!=
time_info_
->
dict_
->
end
())
{
delete
iter
->
second
;
iter
->
second
=
nullptr
;
(
void
)
time_info_
->
dict_
->
erase
(
iter
);
}
(
*
time_info_
->
dict_
)[
name
]
=
time
;
(
*
time_info_
->
dict_
)[
sorted_
name
]
=
time
;
}
bool
ProfContext
::
IsTopContext
()
const
noexcept
{
return
(
prof_
!=
nullptr
)
&&
(
this
==
&
prof_
->
context_
);
}
...
...
mindspore/ccsrc/utils/profile.h
浏览文件 @
b6dd80f8
...
...
@@ -34,12 +34,13 @@ extern double GetTime();
class
ProfileBase
;
struct
TimeInfo
{
explicit
TimeInfo
(
double
time
=
-
1.0
)
:
time_
(
time
),
dict_
(
nullptr
)
{}
explicit
TimeInfo
(
double
time
=
-
1.0
)
:
time_
(
time
),
dict_
(
nullptr
)
,
actionNum_
(
0
)
{}
TimeInfo
(
const
TimeInfo
&
)
=
delete
;
~
TimeInfo
();
double
time_
;
TimeInfoMap
*
dict_
;
size_t
actionNum_
;
};
// Utility class for Profile.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录