mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-18 23:14:35 +08:00
[mpp_time]: Add AUTO_TIMING for C++ function
Signed-off-by: Herman Chen <herman.chen@rock-chips.com> Change-Id: I1ec9f6307dce44f7aa086911477b27e523904cdc
This commit is contained in:
@@ -94,5 +94,26 @@ void mpp_timer_put(MppTimer timer);
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*__MPP_TIME_H__*/
|
#ifdef __cplusplus
|
||||||
|
class AutoTiming
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AutoTiming(const char *name = __FUNCTION__);
|
||||||
|
~AutoTiming();
|
||||||
|
private:
|
||||||
|
const char *mName;
|
||||||
|
RK_S64 mStart;
|
||||||
|
RK_S64 mEnd;
|
||||||
|
|
||||||
|
AutoTiming(const AutoTiming &);
|
||||||
|
AutoTiming &operator = (const AutoTiming&);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define AUTO_TIMER_STRING(name, cnt) name ## cnt
|
||||||
|
#define AUTO_TIMER_NAME_STRING(name, cnt) AUTO_TIMER_STRING(name, cnt)
|
||||||
|
#define AUTO_TIMER_NAME(name) AUTO_TIMER_NAME_STRING(name, __COUNTER__)
|
||||||
|
#define AUTO_TIMING() AutoTiming AUTO_TIMER_NAME(auto_timing)(__FUNCTION__)
|
||||||
|
|
||||||
|
#endif /*__MPP_TIME_H__*/
|
||||||
|
@@ -427,3 +427,15 @@ void mpp_timer_put(MppTimer timer)
|
|||||||
impl = NULL;
|
impl = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AutoTiming::AutoTiming(const char *name)
|
||||||
|
{
|
||||||
|
mStart = mpp_time();
|
||||||
|
mName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoTiming::~AutoTiming()
|
||||||
|
{
|
||||||
|
mEnd = mpp_time();
|
||||||
|
mpp_log("%s timing %lld us\n", mName, mEnd - mStart);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user