Created by: qingqing01
Fix https://github.com/PaddlePaddle/Paddle/issues/6174
The design doc is https://github.com/PaddlePaddle/Paddle/pull/6700 .
The code is divided into two parts: the first part is to use events to record the timeline. The second part is to summarize and show the statistics. All these are C++ code. This PR is the first part.