mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-27 08:41:02 +08:00
Interface changing:
1 - Rename startListeningToCature to startListen 2 - Specify listen port by startListen function parameter
This commit is contained in:
parent
acb197557f
commit
80ebd76116
@ -556,8 +556,8 @@ namespace profiler {
|
|||||||
*/
|
*/
|
||||||
PROFILER_API const char* getContextSwitchLogFilename();
|
PROFILER_API const char* getContextSwitchLogFilename();
|
||||||
|
|
||||||
PROFILER_API void startListenSignalToCapture();
|
PROFILER_API void startListen(uint16_t _port = profiler::DEFAULT_PORT);
|
||||||
PROFILER_API void stopListenSignalToCapture();
|
PROFILER_API void stopListen();
|
||||||
|
|
||||||
/** Returns current major version.
|
/** Returns current major version.
|
||||||
|
|
||||||
@ -604,8 +604,8 @@ namespace profiler {
|
|||||||
inline void setLowPriorityEventTracing(bool) { }
|
inline void setLowPriorityEventTracing(bool) { }
|
||||||
inline void setContextSwitchLogFilename(const char*) { }
|
inline void setContextSwitchLogFilename(const char*) { }
|
||||||
inline const char* getContextSwitchLogFilename() { return ""; }
|
inline const char* getContextSwitchLogFilename() { return ""; }
|
||||||
inline void startListenSignalToCapture() { }
|
inline void startListen(uint16_t _port = profiler::DEFAULT_PORT) { }
|
||||||
inline void stopListenSignalToCapture() { }
|
inline void stopListen() { }
|
||||||
inline uint8_t versionMajor() { return 0; }
|
inline uint8_t versionMajor() { return 0; }
|
||||||
inline uint8_t versionMinor() { return 0; }
|
inline uint8_t versionMinor() { return 0; }
|
||||||
inline uint16_t versionPatch() { return 0; }
|
inline uint16_t versionPatch() { return 0; }
|
||||||
|
@ -207,7 +207,7 @@ int main(int argc, char* argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
EASY_MAIN_THREAD;
|
EASY_MAIN_THREAD;
|
||||||
profiler::startListenSignalToCapture();
|
profiler::startListen();
|
||||||
|
|
||||||
std::vector<std::thread> threads;
|
std::vector<std::thread> threads;
|
||||||
for (int i=0; i < 3; i++) {
|
for (int i=0; i < 3; i++) {
|
||||||
|
@ -14,7 +14,8 @@ probe scheduler.ctxswitch {
|
|||||||
next
|
next
|
||||||
|
|
||||||
//printf("Switch from %d(%s) to %d(%s) at %d\n",prev_tid, prev_task_name,next_tid,next_task_name, gettimeofday_ns())
|
//printf("Switch from %d(%s) to %d(%s) at %d\n",prev_tid, prev_task_name,next_tid,next_task_name, gettimeofday_ns())
|
||||||
printf("%d %d %d\n",gettimeofday_ns(),prev_tid, next_tid )
|
printf("%d %d %d %s\n",gettimeofday_ns(),prev_tid, next_tid, next_task_name )
|
||||||
|
//printf("%d %d %d\n",gettimeofday_ns(),prev_tid, next_tid )
|
||||||
}
|
}
|
||||||
|
|
||||||
probe begin
|
probe begin
|
||||||
|
@ -173,12 +173,12 @@ extern "C" {
|
|||||||
return MANAGER.getContextSwitchLogFilename();
|
return MANAGER.getContextSwitchLogFilename();
|
||||||
}
|
}
|
||||||
|
|
||||||
PROFILER_API void startListenSignalToCapture()
|
PROFILER_API void startListen(uint16_t _port)
|
||||||
{
|
{
|
||||||
return MANAGER.startListenSignalToCapture();
|
return MANAGER.startListenSignalToCapture(_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
PROFILER_API void stopListenSignalToCapture()
|
PROFILER_API void stopListen()
|
||||||
{
|
{
|
||||||
return MANAGER.stopListenSignalToCapture();
|
return MANAGER.stopListenSignalToCapture();
|
||||||
}
|
}
|
||||||
@ -727,8 +727,9 @@ uint32_t ProfileManager::dumpBlocksToStream(profiler::OStream& _outputStream)
|
|||||||
|
|
||||||
std::ifstream infile(m_csInfoFilename.c_str());
|
std::ifstream infile(m_csInfoFilename.c_str());
|
||||||
if(infile.is_open()) {
|
if(infile.is_open()) {
|
||||||
while (infile >> timestamp >> thread_from >> thread_to) {
|
std::string next_task_name;
|
||||||
beginContextSwitch(thread_from, timestamp, thread_to, "", false);
|
while (infile >> timestamp >> thread_from >> thread_to >> next_task_name) {
|
||||||
|
beginContextSwitch(thread_from, timestamp, thread_to, next_task_name.c_str(), false);
|
||||||
endContextSwitch(thread_to, timestamp, false);
|
endContextSwitch(thread_to, timestamp, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -908,12 +909,12 @@ void ProfileManager::setBlockStatus(block_id_t _id, EasyBlockStatus _status)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileManager::startListenSignalToCapture()
|
void ProfileManager::startListenSignalToCapture(uint16_t _port)
|
||||||
{
|
{
|
||||||
if (!m_isAlreadyListened)
|
if (!m_isAlreadyListened)
|
||||||
{
|
{
|
||||||
m_stopListen.store(false, std::memory_order_release);
|
m_stopListen.store(false, std::memory_order_release);
|
||||||
m_listenThread = std::move(std::thread(&ProfileManager::listen, this));
|
m_listenThread = std::move(std::thread(&ProfileManager::listen, this, _port));
|
||||||
m_isAlreadyListened = true;
|
m_isAlreadyListened = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -930,14 +931,14 @@ void ProfileManager::stopListenSignalToCapture()
|
|||||||
|
|
||||||
//#define EASY_DEBUG_NET_PRINT
|
//#define EASY_DEBUG_NET_PRINT
|
||||||
|
|
||||||
void ProfileManager::listen()
|
void ProfileManager::listen(uint16_t _port)
|
||||||
{
|
{
|
||||||
EASY_THREAD_SCOPE("EasyProfiler.Listen");
|
EASY_THREAD_SCOPE("EasyProfiler.Listen");
|
||||||
|
|
||||||
EasySocket socket;
|
EasySocket socket;
|
||||||
profiler::net::Message replyMessage(profiler::net::MESSAGE_TYPE_REPLY_START_CAPTURING);
|
profiler::net::Message replyMessage(profiler::net::MESSAGE_TYPE_REPLY_START_CAPTURING);
|
||||||
|
|
||||||
socket.bind(profiler::DEFAULT_PORT);
|
socket.bind(_port);
|
||||||
int bytes = 0;
|
int bytes = 0;
|
||||||
while (!m_stopListen.load(std::memory_order_acquire))
|
while (!m_stopListen.load(std::memory_order_acquire))
|
||||||
{
|
{
|
||||||
|
@ -368,7 +368,7 @@ class ProfileManager
|
|||||||
|
|
||||||
std::thread m_listenThread;
|
std::thread m_listenThread;
|
||||||
bool m_isAlreadyListened = false;
|
bool m_isAlreadyListened = false;
|
||||||
void listen();
|
void listen(uint16_t _port);
|
||||||
|
|
||||||
int m_socket = 0;//TODO crossplatform
|
int m_socket = 0;//TODO crossplatform
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ public:
|
|||||||
void beginContextSwitch(profiler::thread_id_t _thread_id, profiler::timestamp_t _time, profiler::thread_id_t _target_thread_id, const char* _target_process, bool _lockSpin = true);
|
void beginContextSwitch(profiler::thread_id_t _thread_id, profiler::timestamp_t _time, profiler::thread_id_t _target_thread_id, const char* _target_process, bool _lockSpin = true);
|
||||||
void storeContextSwitch(profiler::thread_id_t _thread_id, profiler::timestamp_t _time, profiler::thread_id_t _target_thread_id, bool _lockSpin = true);
|
void storeContextSwitch(profiler::thread_id_t _thread_id, profiler::timestamp_t _time, profiler::thread_id_t _target_thread_id, bool _lockSpin = true);
|
||||||
void endContextSwitch(profiler::thread_id_t _thread_id, profiler::timestamp_t _endtime, bool _lockSpin = true);
|
void endContextSwitch(profiler::thread_id_t _thread_id, profiler::timestamp_t _endtime, bool _lockSpin = true);
|
||||||
void startListenSignalToCapture();
|
void startListenSignalToCapture(uint16_t _port);
|
||||||
void stopListenSignalToCapture();
|
void stopListenSignalToCapture();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user