提交 f9b81685 编写于 作者: D dongdaxiang

Merge branch 'add_timer' of https://github.com/guru4elephant/Paddle into add_timer

test=develop
...@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and ...@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#pragma once #pragma once
#include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>
#include "paddle/fluid/framework/scope.h"
namespace paddle { namespace paddle {
namespace platform { namespace platform {
...@@ -22,14 +22,21 @@ namespace platform { ...@@ -22,14 +22,21 @@ namespace platform {
// A Standard Timer implementation for debugging // A Standard Timer implementation for debugging
class Timer { class Timer {
public: public:
// a timer class for profiling
// Reset() will be called during initialization
// all timing variables will be set 0 in Reset()
Timer() { Reset(); } Timer() { Reset(); }
void Reset(); void Reset();
void Start(); void Start();
void Pause(); void Pause();
// Resume will get current system time
void Resume(); void Resume();
int Count(); int Count();
// return elapsed time in us
double ElapsedUS(); double ElapsedUS();
// return elapsed time in ms
double ElapsedMS(); double ElapsedMS();
// return elapsed time in sec
double ElapsedSec(); double ElapsedSec();
private: private:
...@@ -39,6 +46,7 @@ class Timer { ...@@ -39,6 +46,7 @@ class Timer {
int _elapsed; int _elapsed;
bool _paused; bool _paused;
// get us difference between start and now
int64_t Tickus(); int64_t Tickus();
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册