Skip to content

Commit edd4a13

Browse files
authored
Merge pull request #11824 from reyoung/cherry_pick_timeline_cn
add timeline_cn
2 parents 291e849 + b02c2b4 commit edd4a13

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# 如何使用timeline工具做性能分析
2+
3+
1. 在训练的主循环外加上`with profiler.profiler(...)`。运行之后,代码会在`/tmp/profile`目录下生成一个profile的记录文件。
4+
5+
**提示:**
6+
请不要在timeline记录信息时运行太多次迭代,因为timeline中的记录数量和迭代次数是成正比的。
7+
8+
```python
9+
with profiler.profiler('All', 'total', '/tmp/profile') as prof:
10+
for pass_id in range(pass_num):
11+
for batch_id, data in enumerate(train_reader()):
12+
exe.run(fluid.default_main_program(),
13+
feed=feeder.feed(data),
14+
fetch_list=[])
15+
...
16+
```
17+
18+
1. 运行`python paddle/tools/timeline.py`来处理`/tmp/profile`,这个程序默认会生成一个`/tmp/timeline`文件,你也可以用命令行参数来修改这个路径,请参考[timeline.py](https://github.com/PaddlePaddle/Paddle/blob/develop/tools/timeline.py)
19+
20+
1. 打开chrome浏览器,访问<chrome://tracing/>,用`load`按钮来加载生成的`timeline`文件。
21+
22+
![chrome tracing](./tracing.jpeg)
23+
24+
1. 结果如下图所示,可以放到来查看timetime的细节信息。
25+
26+
![chrome timeline](./timeline.jpeg)
File renamed without changes.

0 commit comments

Comments
 (0)