0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-26 16:11:02 +08:00

Rename directory profiler to easy

This commit is contained in:
Sergey Yagovtsev 2016-09-29 23:29:57 +03:00
parent eca7061fd0
commit 76defe2372
29 changed files with 142 additions and 135 deletions

View File

@ -19,7 +19,7 @@ along with this program.If not, see <http://www.gnu.org/licenses/>.
#define EASY________SOCKET_________H #define EASY________SOCKET_________H
#include <stdint.h> #include <stdint.h>
#include "profiler/profiler.h" #include "easy/profiler.h"
#ifndef _WIN32 #ifndef _WIN32
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>

View File

@ -19,7 +19,7 @@ along with this program.If not, see <http://www.gnu.org/licenses/>.
#ifndef EASY_PROFILER____H_______ #ifndef EASY_PROFILER____H_______
#define EASY_PROFILER____H_______ #define EASY_PROFILER____H_______
#include "profiler/profiler_aux.h" #include "easy/profiler_aux.h"
#if defined ( __clang__ ) #if defined ( __clang__ )
# pragma clang diagnostic push # pragma clang diagnostic push
@ -44,7 +44,7 @@ namespace profiler {
/** Macro for beginning of a block with custom name and color. /** Macro for beginning of a block with custom name and color.
\code \code
#include "profiler/profiler.h" #include "easy/profiler.h"
void foo() void foo()
{ {
// some code ... // some code ...
@ -83,7 +83,7 @@ Block will be automatically completed by destructor.
/** Macro for beginning of a block with function name and custom color. /** Macro for beginning of a block with function name and custom color.
\code \code
#include "profiler/profiler.h" #include "easy/profiler.h"
void foo(){ void foo(){
EASY_FUNCTION(); // Block with name="foo" and default color EASY_FUNCTION(); // Block with name="foo" and default color
//some code... //some code...
@ -113,7 +113,7 @@ Name of the block automatically created with function name.
/** Macro for completion of last opened block. /** Macro for completion of last opened block.
\code \code
#include "profiler/profiler.h" #include "easy/profiler.h"
int foo() int foo()
{ {
// some code ... // some code ...

View File

@ -32,8 +32,8 @@
#define EASY_PROFILER__AUX__H_______ #define EASY_PROFILER__AUX__H_______
#include <stdint.h> #include <stdint.h>
#include "profiler/easy_compiler_support.h" #include "easy/easy_compiler_support.h"
#include "profiler/profiler_colors.h" #include "easy/profiler_colors.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -61,6 +61,7 @@ namespace profiler {
#ifndef FULL_DISABLE_PROFILER #ifndef FULL_DISABLE_PROFILER
#include <type_traits> #include <type_traits>
#include <string>
# define EASY_STRINGIFY(a) #a # define EASY_STRINGIFY(a) #a
# define EASY_STRINGIFICATION(a) EASY_STRINGIFY(a) # define EASY_STRINGIFICATION(a) EASY_STRINGIFY(a)
@ -73,11 +74,19 @@ namespace profiler {
template <const bool IS_REF> struct NameSwitch EASY_FINAL { template <const bool IS_REF> struct NameSwitch EASY_FINAL {
static const char* runtime_name(const char* name) { return name; } static const char* runtime_name(const char* name) { return name; }
static const char* runtime_name(const std::string& name) { return name.c_str(); }
template <class T>
static const char* compiletime_name(const T&, const char* autoGeneratedName) { return autoGeneratedName; }
static const char* compiletime_name(const char*, const char* autoGeneratedName) { return autoGeneratedName; } static const char* compiletime_name(const char*, const char* autoGeneratedName) { return autoGeneratedName; }
}; };
template <> struct NameSwitch<true> EASY_FINAL { template <> struct NameSwitch<true> EASY_FINAL {
static const char* runtime_name(const char*) { return ""; } static const char* runtime_name(const char*) { return ""; }
static const char* runtime_name(const std::string& name) { return name.c_str(); }
template <class T>
static const char* compiletime_name(const T&, const char* autoGeneratedName) { return autoGeneratedName; }
static const char* compiletime_name(const char* name, const char*) { return name; } static const char* compiletime_name(const char* name, const char*) { return name; }
}; };

View File

@ -25,8 +25,8 @@ along with this program.If not, see <http://www.gnu.org/licenses/>.
#include <vector> #include <vector>
#include <string> #include <string>
#include <atomic> #include <atomic>
#include "profiler/profiler.h" #include "easy/profiler.h"
#include "profiler/serialized_block.h" #include "easy/serialized_block.h"
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -82,8 +82,8 @@ namespace profiler {
children_t children; ///< List of children blocks. May be empty. children_t children; ///< List of children blocks. May be empty.
::profiler::SerializedBlock* node; ///< Pointer to serilized data (type, name, begin, end etc.) ::profiler::SerializedBlock* node; ///< Pointer to serilized data (type, name, begin, end etc.)
::profiler::BlockStatistics* per_parent_stats; ///< Pointer to statistics for this block within the parent (may be nullptr for top-level blocks) ::profiler::BlockStatistics* per_parent_stats; ///< Pointer to statistics for this block within the parent (may be nullptr for top-level blocks)
::profiler::BlockStatistics* per_frame_stats; ///< Pointer to statistics for this block within the frame (may be nullptr for top-level blocks) ::profiler::BlockStatistics* per_frame_stats; ///< Pointer to statistics for this block within the frame (may be nullptr for top-level blocks)
::profiler::BlockStatistics* per_thread_stats; ///< Pointer to statistics for this block within the bounds of all frames per current thread ::profiler::BlockStatistics* per_thread_stats; ///< Pointer to statistics for this block within the bounds of all frames per current thread
uint16_t depth; ///< Maximum number of sublevels (maximum children depth) uint16_t depth; ///< Maximum number of sublevels (maximum children depth)

View File

@ -19,7 +19,7 @@ along with this program.If not, see <http://www.gnu.org/licenses/>.
#ifndef EASY_PROFILER_SERIALIZED_BLOCK__H_______ #ifndef EASY_PROFILER_SERIALIZED_BLOCK__H_______
#define EASY_PROFILER_SERIALIZED_BLOCK__H_______ #define EASY_PROFILER_SERIALIZED_BLOCK__H_______
#include "profiler/profiler.h" #include "easy/profiler.h"
namespace profiler { namespace profiler {

View File

@ -11,8 +11,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5Widgets REQUIRED) find_package(Qt5Widgets REQUIRED)
find_package(Qt5Network REQUIRED) find_package(Qt5Network REQUIRED)
include_directories(${ROOT}/3rdparty/nanomsg/src)
add_executable(${PROJECT_NAME} add_executable(${PROJECT_NAME}
main.cpp main.cpp
blocks_graphics_view.h blocks_graphics_view.h

View File

@ -46,7 +46,7 @@
#include <QPoint> #include <QPoint>
#include <QRectF> #include <QRectF>
#include <QTimer> #include <QTimer>
#include "profiler/reader.h" #include "easy/reader.h"
#include "common_types.h" #include "common_types.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -42,7 +42,7 @@
#include <QTreeWidget> #include <QTreeWidget>
#include <QTimer> #include <QTimer>
#include "tree_widget_loader.h" #include "tree_widget_loader.h"
#include "profiler/reader.h" #include "easy/reader.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -38,7 +38,7 @@
#include <QRgb> #include <QRgb>
#include <QString> #include <QString>
#include <QFont> #include <QFont>
#include "profiler/reader.h" #include "easy/reader.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -35,7 +35,7 @@
#include <QTreeWidget> #include <QTreeWidget>
#include <QString> #include <QString>
#include <vector> #include <vector>
#include "profiler/profiler.h" #include "easy/profiler.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -36,7 +36,7 @@
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QRectF> #include <QRectF>
#include <QString> #include <QString>
#include "profiler/reader.h" #include "easy/reader.h"
#include "common_types.h" #include "common_types.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -32,7 +32,7 @@
#define EASY__GLOBALS_QOBJECTS_H___ #define EASY__GLOBALS_QOBJECTS_H___
#include <QObject> #include <QObject>
#include "profiler/profiler.h" #include "easy/profiler.h"
namespace profiler_gui { namespace profiler_gui {

View File

@ -30,7 +30,7 @@
//#include <QFileSystemModel> //#include <QFileSystemModel>
//#include "treemodel.h" //#include "treemodel.h"
#include "main_window.h" #include "main_window.h"
#include "profiler/reader.h" #include "easy/reader.h"
//#ifdef _WIN32 //#ifdef _WIN32

View File

@ -64,7 +64,7 @@
#include "blocks_graphics_view.h" #include "blocks_graphics_view.h"
#include "descriptors_tree_widget.h" #include "descriptors_tree_widget.h"
#include "globals.h" #include "globals.h"
#include "profiler/easy_net.h" #include "easy/easy_net.h"
#ifdef max #ifdef max
#undef max #undef max
@ -658,7 +658,7 @@ void EasyMainWindow::onListenerDialogClose(int)
break; break;
} }
default: default:
return; return;
} }
@ -1048,60 +1048,60 @@ void EasyMainWindow::onBlockStatusChange(::profiler::block_id_t _id, ::profiler:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EasySocketListener::EasySocketListener() : m_receivedSize(0), m_regime(LISTENER_IDLE) EasySocketListener::EasySocketListener() : m_receivedSize(0), m_regime(LISTENER_IDLE)
{ {
m_bInterrupt = ATOMIC_VAR_INIT(false); m_bInterrupt = ATOMIC_VAR_INIT(false);
m_bConnected = ATOMIC_VAR_INIT(false); m_bConnected = ATOMIC_VAR_INIT(false);
} }
EasySocketListener::~EasySocketListener() EasySocketListener::~EasySocketListener()
{ {
m_bInterrupt.store(true, ::std::memory_order_release); m_bInterrupt.store(true, ::std::memory_order_release);
if (m_thread.joinable()) if (m_thread.joinable())
m_thread.join(); m_thread.join();
} }
bool EasySocketListener::connected() const bool EasySocketListener::connected() const
{ {
return m_bConnected.load(::std::memory_order_acquire); return m_bConnected.load(::std::memory_order_acquire);
} }
EasyListenerRegime EasySocketListener::regime() const EasyListenerRegime EasySocketListener::regime() const
{ {
return m_regime; return m_regime;
} }
uint64_t EasySocketListener::size() const uint64_t EasySocketListener::size() const
{ {
return m_receivedSize; return m_receivedSize;
} }
::std::stringstream& EasySocketListener::data() ::std::stringstream& EasySocketListener::data()
{ {
return m_receivedData; return m_receivedData;
} }
void EasySocketListener::clearData() void EasySocketListener::clearData()
{ {
decltype(m_receivedData) dummy; decltype(m_receivedData) dummy;
dummy.swap(m_receivedData); dummy.swap(m_receivedData);
m_receivedSize = 0; m_receivedSize = 0;
} }
bool EasySocketListener::connect(const char* _ipaddress, uint16_t _port, profiler::net::EasyProfilerStatus& _reply) bool EasySocketListener::connect(const char* _ipaddress, uint16_t _port, profiler::net::EasyProfilerStatus& _reply)
{ {
if (connected()) if (connected())
return true; return true;
m_easySocket.flush(); m_easySocket.flush();
m_easySocket.init(); m_easySocket.init();
int res = m_easySocket.setAddress(_ipaddress, _port); int res = m_easySocket.setAddress(_ipaddress, _port);
res = m_easySocket.connect(); res = m_easySocket.connect();
const bool isConnected = res == 0; const bool isConnected = res == 0;
if (isConnected) if (isConnected)
{ {
static const size_t buffer_size = sizeof(profiler::net::EasyProfilerStatus) << 1; static const size_t buffer_size = sizeof(profiler::net::EasyProfilerStatus) << 1;
char buffer[buffer_size] = {}; char buffer[buffer_size] = {};
int bytes = 0; int bytes = 0;
@ -1122,7 +1122,7 @@ bool EasySocketListener::connect(const char* _ipaddress, uint16_t _port, profile
if (bytes == 0) if (bytes == 0)
{ {
m_bConnected.store(isConnected, ::std::memory_order_release); m_bConnected.store(isConnected, ::std::memory_order_release);
return isConnected; return isConnected;
} }
@ -1144,50 +1144,50 @@ bool EasySocketListener::connect(const char* _ipaddress, uint16_t _port, profile
auto message = reinterpret_cast<const ::profiler::net::EasyProfilerStatus*>(buffer); auto message = reinterpret_cast<const ::profiler::net::EasyProfilerStatus*>(buffer);
if (message->isEasyNetMessage() && message->type == profiler::net::MESSAGE_TYPE_ACCEPTED_CONNECTION) if (message->isEasyNetMessage() && message->type == profiler::net::MESSAGE_TYPE_ACCEPTED_CONNECTION)
_reply = *message; _reply = *message;
} }
m_bConnected.store(isConnected, ::std::memory_order_release); m_bConnected.store(isConnected, ::std::memory_order_release);
return isConnected; return isConnected;
} }
void EasySocketListener::startCapture() void EasySocketListener::startCapture()
{ {
clearData(); clearData();
profiler::net::Message request(profiler::net::MESSAGE_TYPE_REQUEST_START_CAPTURE); profiler::net::Message request(profiler::net::MESSAGE_TYPE_REQUEST_START_CAPTURE);
m_easySocket.send(&request, sizeof(request)); m_easySocket.send(&request, sizeof(request));
m_regime = LISTENER_CAPTURE; m_regime = LISTENER_CAPTURE;
m_thread = ::std::move(::std::thread(&EasySocketListener::listenCapture, this)); m_thread = ::std::move(::std::thread(&EasySocketListener::listenCapture, this));
} }
void EasySocketListener::stopCapture() void EasySocketListener::stopCapture()
{ {
if (!m_thread.joinable() || m_regime != LISTENER_CAPTURE) if (!m_thread.joinable() || m_regime != LISTENER_CAPTURE)
return; return;
profiler::net::Message request(profiler::net::MESSAGE_TYPE_REQUEST_STOP_CAPTURE); profiler::net::Message request(profiler::net::MESSAGE_TYPE_REQUEST_STOP_CAPTURE);
m_easySocket.send(&request, sizeof(request)); m_easySocket.send(&request, sizeof(request));
m_thread.join(); m_thread.join();
m_regime = LISTENER_IDLE; m_regime = LISTENER_IDLE;
} }
void EasySocketListener::requestBlocksDescription() void EasySocketListener::requestBlocksDescription()
{ {
clearData(); clearData();
profiler::net::Message request(profiler::net::MESSAGE_TYPE_REQUEST_BLOCKS_DESCRIPTION); profiler::net::Message request(profiler::net::MESSAGE_TYPE_REQUEST_BLOCKS_DESCRIPTION);
m_easySocket.send(&request, sizeof(request)); m_easySocket.send(&request, sizeof(request));
m_regime = LISTENER_DESCRIBE; m_regime = LISTENER_DESCRIBE;
listenDescription(); listenDescription();
m_regime = LISTENER_IDLE; m_regime = LISTENER_IDLE;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasySocketListener::listenCapture() void EasySocketListener::listenCapture()
{ {
// TODO: Merge functions listenCapture() and listenDescription() // TODO: Merge functions listenCapture() and listenDescription()

View File

@ -38,8 +38,8 @@
#include <QMainWindow> #include <QMainWindow>
#include <QTimer> #include <QTimer>
#include "profiler/easy_socket.h" #include "easy/easy_socket.h"
#include "profiler/reader.h" #include "easy/reader.h"
#ifdef max #ifdef max
#undef max #undef max
@ -110,8 +110,8 @@ class EasySocketListener Q_DECL_FINAL
{ {
EasySocket m_easySocket; ///< EasySocket m_easySocket; ///<
::std::stringstream m_receivedData; ///< ::std::stringstream m_receivedData; ///<
::std::thread m_thread; ///< ::std::thread m_thread; ///<
uint64_t m_receivedSize; ///< uint64_t m_receivedSize; ///<
::std::atomic_bool m_bInterrupt; ///< ::std::atomic_bool m_bInterrupt; ///<
::std::atomic_bool m_bConnected; ///< ::std::atomic_bool m_bConnected; ///<
EasyListenerRegime m_regime; ///< EasyListenerRegime m_regime; ///<

View File

@ -35,7 +35,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <QTreeWidget> #include <QTreeWidget>
#include "profiler/reader.h" #include "easy/reader.h"
#include "common_types.h" #include "common_types.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -37,7 +37,7 @@
#include <vector> #include <vector>
#include <thread> #include <thread>
#include <atomic> #include <atomic>
#include "profiler/reader.h" #include "easy/reader.h"
#include "common_types.h" #include "common_types.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
#include "profiler/profiler.h" #include "easy/profiler.h"
#include "profiler/reader.h" #include "easy/reader.h"
#include <fstream> #include <fstream>
#include <list> #include <list>
#include <iostream> #include <iostream>

View File

@ -1,11 +1,11 @@
//#define FULL_DISABLE_PROFILER //#define FULL_DISABLE_PROFILER
#include "profiler/profiler.h" #include "easy/profiler.h"
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include <condition_variable> #include <condition_variable>
#include "profiler/reader.h" #include "easy/reader.h"
#include <cstdlib> #include <cstdlib>
#include <math.h> #include <math.h>

View File

@ -9,10 +9,10 @@ set(CPP_FILES
) )
set(H_FILES set(H_FILES
${ROOT}/include/profiler/profiler.h ${ROOT}/include/easy/profiler.h
${ROOT}/include/profiler/reader.h ${ROOT}/include/easy/reader.h
${ROOT}/include/profiler/easy_net.h ${ROOT}/include/easy/easy_net.h
${ROOT}/include/profiler/easy_socket.h ${ROOT}/include/easy/easy_socket.h
profile_manager.h profile_manager.h
spin_lock.h spin_lock.h
event_trace_win.h event_trace_win.h

View File

@ -19,7 +19,7 @@ along with this program.If not, see <http://www.gnu.org/licenses/>.
#ifndef EASY_______CURRENT_TIME_H_____ #ifndef EASY_______CURRENT_TIME_H_____
#define EASY_______CURRENT_TIME_H_____ #define EASY_______CURRENT_TIME_H_____
#include "profiler/profiler.h" #include "easy/profiler.h"
#ifdef _WIN32 #ifdef _WIN32
#include <Windows.h> #include <Windows.h>

View File

@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>. along with this program.If not, see <http://www.gnu.org/licenses/>.
**/ **/
#include "profiler/easy_socket.h" #include "easy/easy_socket.h"
#include <string.h> #include <string.h>
#include <thread> #include <thread>

View File

@ -36,7 +36,7 @@
#include <memory.h> #include <memory.h>
#include <chrono> #include <chrono>
#include <unordered_map> #include <unordered_map>
#include "profiler/profiler.h" #include "easy/profiler.h"
#include "profile_manager.h" #include "profile_manager.h"
#include "current_time.h" #include "current_time.h"

View File

@ -27,9 +27,9 @@
#include <algorithm> #include <algorithm>
#include <fstream> #include <fstream>
#include "profile_manager.h" #include "profile_manager.h"
#include "profiler/serialized_block.h" #include "easy/serialized_block.h"
#include "profiler/easy_net.h" #include "easy/easy_net.h"
#include "profiler/easy_socket.h" #include "easy/easy_socket.h"
#include "event_trace_win.h" #include "event_trace_win.h"
#include "current_time.h" #include "current_time.h"

View File

@ -19,8 +19,8 @@ along with this program.If not, see <http://www.gnu.org/licenses/>.
#ifndef EASY_PROFILER____MANAGER____H______ #ifndef EASY_PROFILER____MANAGER____H______
#define EASY_PROFILER____MANAGER____H______ #define EASY_PROFILER____MANAGER____H______
#include "profiler/profiler.h" #include "easy/profiler.h"
#include "profiler/easy_socket.h" #include "easy/easy_socket.h"
#include "spin_lock.h" #include "spin_lock.h"
#include "outstream.h" #include "outstream.h"
#include "hashed_cstr.h" #include "hashed_cstr.h"

View File

@ -42,7 +42,7 @@
* : along with this program.If not, see <http://www.gnu.org/licenses/>. * : along with this program.If not, see <http://www.gnu.org/licenses/>.
************************************************************************/ ************************************************************************/
#include "profiler/reader.h" #include "easy/reader.h"
#include "hashed_cstr.h" #include "hashed_cstr.h"
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>