Add profiling viewer extension.

Summary:
Due to splitting efl_profiling_viewer to the library this
extension was prepared. This is a first version of extension and will be
improved. After @Deepwarrior will publish code for efl_profiling_viewer that
make possible to work with real time data from efl_debug system, it will
be possible compile clouseau with efl_profiling_viewer support.

Test Plan:
Inctall Profiling_Viewer library in the system.
Build clouseau.
Launch clouseau and select Profiling viewer extesion.

Reviewers: Deepwarrior, JackDanielZ

Reviewed By: Deepwarrior

Tags: #clouseau, PHID-PROJ-w56dx3enc43oqdzz2xpa

Differential Revision: https://phab.enlightenment.org/D5061
This commit is contained in:
Mykyta Biliavskyi 2017-09-01 14:06:21 +03:00
parent 26c85dda2d
commit 170923b164
5 changed files with 252 additions and 0 deletions

View File

@ -18,6 +18,7 @@ find_package(Elementary REQUIRED)
find_package(Ecore REQUIRED)
find_package(Evas REQUIRED)
find_package(Ffi REQUIRED)
find_package(efl_profiler)
add_subdirectory(src/bin)
add_subdirectory(src/lib)

View File

@ -317,6 +317,13 @@ _configs_load()
_config->extensions_cfgs = eina_list_append(_config->extensions_cfgs, ext_cfg);
}
if (!_ext_cfg_find_by_path(INSTALL_PREFIX"/lib/libclouseau_profiling_viewer.so"))
{
ext_cfg = calloc(1, sizeof(*ext_cfg));
ext_cfg->lib_path = eina_stringshare_add(INSTALL_PREFIX"/lib/libclouseau_profiling_viewer.so");
_config->extensions_cfgs = eina_list_append(_config->extensions_cfgs, ext_cfg);
}
_config_save();
}

View File

@ -1,2 +1,6 @@
add_subdirectory(objects_introspection)
add_subdirectory(evlog)
if (${EFL_PROFILER_FOUND})
add_subdirectory(profiling_viewer)
endif (${EFL_PROFILER_FOUND})

View File

@ -0,0 +1,39 @@
set(CMAKE_BUILD_TYPE Debug)
STRING(REGEX REPLACE "\n" "" EOLIAN_EO_DIR ${EOLIAN_EO_DIR})
STRING(REGEX REPLACE " " "" EOLIAN_EO_DIR ${EOLIAN_EO_DIR})
add_definitions(${CLI_COMMON_DEFINITIONS} -DEFL_EO_API_SUPPORT
-DEOLIAN_EO_DIR="${EOLIAN_EO_DIR}")
add_definitions(-DEFL_EO_API_SUPPORT -DGUI_IMAGES_PATH="${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME_LOWER}")
set(EOLIAN_INCLUDE_FLAG -I \"${EOLIAN_EO_DIR}/eo-1\" -I${CMAKE_CURRENT_SOURCE_DIR})
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${EFL_PROFILER_INCLUDE_DIRS}
${ELEMENTARY_INCLUDE_DIRS}
${EVAS_INCLUDE_DIRS}
${EO_INCLUDE_DIRS}
${EINA_INCLUDE_DIRS}
${EET_INCLUDE_DIRS}
${EOLIAN_INCLUDE_DIRS}
)
link_directories (${PC_LIBELEMENTARY_LIBRARY_DIRS})
add_library(clouseau_profiling_viewer SHARED main.c)
target_link_libraries(clouseau_profiling_viewer
efl_profiler
${ELEMENTARY_LIBRARIES}
${EVAS_LIBRARIES}
${EO_LIBRARIES}
${EINA_LIBRARIES}
${EET_LIBRARIES}
${EOLIAN_LIBRARIES}
)
INSTALL(TARGETS clouseau_profiling_viewer LIBRARY DESTINATION lib)

View File

@ -0,0 +1,201 @@
#include <Eina.h>
#include <Elementary.h>
#include <Efl_Profiler.h>
#include "../../Clouseau.h"
#define _EET_ENTRY "config"
typedef enum {
STREAM_STOPPED = 0,
STREAM_PROCESSING,
STREAM_PAUSED
} CLOUSEAU_PROFILER_STATUS;
typedef struct {
Evas_Object *profiler;
Ecore_Timer *record_get_timer;
struct {
CLOUSEAU_PROFILER_STATUS status; /*<< 0 - stopped, 1 - processing, 2 - paused */
} stream;
} Inf;
static int _clouseau_profiling_extension_log_dom = 0;
static int _record_on_op = EINA_DEBUG_OPCODE_INVALID;
static int _record_off_op = EINA_DEBUG_OPCODE_INVALID;
static int _record_get_op = EINA_DEBUG_OPCODE_INVALID;
static Eina_Bool _record_get_cb(Eina_Debug_Session *, int, void *, int);
EINA_DEBUG_OPCODES_ARRAY_DEFINE(_ops,
{"CPU/Freq/on", &_record_on_op, NULL},
{"CPU/Freq/off", &_record_off_op, NULL},
{"EvLog/get", &_record_get_op, &_record_get_cb},
{NULL, NULL, NULL}
);
EAPI const char *
extension_name_get()
{
return "Profiling viewer";
}
static Eina_Bool
_record_request_cb(void *data)
{
Clouseau_Extension *ext = data;
eina_debug_session_send(ext->session, ext->app_id, _record_get_op, NULL, 0);
return EINA_TRUE;
}
static void
_stream_processing_pause_cb(void *data,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Clouseau_Extension *ext = data;
Inf *inf = ext->data;
eina_debug_session_send(ext->session, ext->app_id, _record_off_op, NULL, 0);
ecore_timer_del(inf->record_get_timer);
}
static void
_stream_processing_resume_cb(void *data,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Clouseau_Extension *ext = data;
Inf *inf = ext->data;
eina_debug_session_send(ext->session, ext->app_id, _record_on_op, NULL, 0);
if (!inf->record_get_timer)
inf->record_get_timer = ecore_timer_add(0.2, _record_request_cb, ext);
}
static void
_session_changed(Clouseau_Extension *ext)
{
Inf *inf = ext->data;
int i = 0;
Eina_Debug_Opcode *ops = _ops();
switch (inf->stream.status)
{
case STREAM_PROCESSING:
evas_object_smart_callback_call(inf->profiler, "stream,processing,pause", NULL);
break;
case STREAM_PAUSED:
case STREAM_STOPPED:
default:
evas_object_smart_callback_call(inf->profiler, "stream,processing,resume", NULL);
}
EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Session changed");
while (ops[i].opcode_name)
{
if (ops[i].opcode_id) *(ops[i].opcode_id) = EINA_DEBUG_OPCODE_INVALID;
i++;
}
if (ext->session)
{
eina_debug_session_data_set(ext->session, ext);
eina_debug_opcodes_register(ext->session, ops, NULL, NULL);
}
return;
}
static void
_app_changed(Clouseau_Extension *ext)
{
Inf *inf = ext->data;
evas_object_smart_callback_call(inf->profiler, "stream,processing,stop", &ext->app_id);
EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Application changed");
return;
}
static void
_profiling_import(Clouseau_Extension *ext,
void *buffer, int size,
int version EINA_UNUSED)
{
EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Data imported");
Inf *inf = ext->data;
Stream_Block_Data block_data = { .size = size, .data = buffer };
evas_object_smart_callback_call(inf->profiler, "stream,block,process", &block_data);
_stream_processing_resume_cb(ext,NULL, NULL);
return;
}
static Eina_Bool
_record_get_cb(Eina_Debug_Session *session, int cid EINA_UNUSED, void *buffer, int size)
{
Clouseau_Extension *ext = eina_debug_session_data_get(session);
_profiling_import(ext, buffer, size, -1);
return EINA_TRUE;
}
static Eo *
_ui_get(Clouseau_Extension *ext, Eo *parent)
{
Inf *inf = ext->data;
inf->profiler = efl_profiling_viewer_init(parent);
evas_object_size_hint_weight_set(inf->profiler, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(inf->profiler, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(inf->profiler, "stream,processing,pause",
_stream_processing_pause_cb, ext);
evas_object_smart_callback_add(inf->profiler, "stream,processing,resume",
_stream_processing_resume_cb, ext);
return inf->profiler;
}
EAPI Eina_Bool
extension_start(Clouseau_Extension *ext, Eo *parent)
{
Inf *inf;
eina_init();
const char *log_dom = "clouseau_profiling_extension";
_clouseau_profiling_extension_log_dom = eina_log_domain_register(log_dom, EINA_COLOR_ORANGE);
if (_clouseau_profiling_extension_log_dom < 0)
{
EINA_LOG_ERR("Could not register log domain: %s", log_dom);
return EINA_FALSE;
}
EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Extension started");
inf = calloc(1, sizeof(Inf));
ext->data = inf;
ext->session_changed_cb = _session_changed;
ext->app_changed_cb = _app_changed;
ext->import_data_cb = _profiling_import;
ext->ui_object = _ui_get(ext, parent);
return !!ext->ui_object;
}
EAPI Eina_Bool
extension_stop(Clouseau_Extension *ext)
{
Inf *inf = ext->data;
evas_object_smart_callback_call(inf->profiler, "log,close", NULL);
efl_del(ext->ui_object);
free(inf);
EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Extension stopped");
eina_log_domain_unregister(_clouseau_profiling_extension_log_dom);
eina_shutdown();
return EINA_TRUE;
}