#include "common/profiler.h"
#include <math.h>
+#include <ttrace.h>
#include "common/logger.h"
#include "common/string_utils.h"
<< func << ":" << tag;
}
-ScopeProfile::ScopeProfile(const char* step) : step_(step), expired_(false) {
+ScopeProfile::ScopeProfile(const char* step, const bool isStep)
+ : step_(step), expired_(false), isStep_(isStep) {
clock_gettime(CLOCK_REALTIME, &start_);
PrintProfileLog(step, "START");
+
+ if(isStep_)
+ traceAsyncBegin(TTRACE_TAG_WEB, 0, "%s%s", "XWALK:", step_.c_str());
+ else
+ traceBegin(TTRACE_TAG_WEB,"%s%s", "XWALK:", step_.c_str());
}
ScopeProfile::~ScopeProfile() {
- if (!expired_)
+ if (!expired_) {
PrintProfileTime(step_.c_str(), start_);
+
+ if(isStep_)
+ traceAsyncEnd(TTRACE_TAG_WEB, 0, "%s%s", "XWALK:", step_.c_str());
+ else
+ traceEnd(TTRACE_TAG_WEB);
+ }
}
void ScopeProfile::Reset() {
clock_gettime(CLOCK_REALTIME, &start_);
PrintProfileLog(step_.c_str(), "START-updated");
+
+ if(isStep_)
+ traceAsyncEnd(TTRACE_TAG_WEB, 0, "%s%s", "XWALK:", step_.c_str());
+ else
+ traceEnd(TTRACE_TAG_WEB);
}
void ScopeProfile::End() {
}
void StepProfile::Start(const char* step) {
- map_[step].reset(new ScopeProfile(step));
+ map_[step].reset(new ScopeProfile(step, true));
}
void StepProfile::End(const char* step) {
class ScopeProfile {
public:
- explicit ScopeProfile(const char* step);
+ explicit ScopeProfile(const char* step, const bool isStep);
~ScopeProfile();
void Reset();
void End();
std::string step_;
struct timespec start_;
bool expired_;
+ bool isStep_;
};
class StepProfile {
} // namespace common
#define SCOPE_PROFILE() \
- common::ScopeProfile __profile(__FUNCTION__);
+ common::ScopeProfile __profile(__FUNCTION__, false);
#define STEP_PROFILE_START(x) \
common::StepProfile::GetInstance()->Start(x)