}
}
+void
+_e_info_client_proc_key_elapsed_time(int argc, char **argv)
+{
+ int count = 0;
+
+ if (argc == 3)
+ {
+ count = atoi(argv[2]);
+ if (count <= 0)
+ {
+ printf("Error Check Args: enlightenment_info -key_elapsed_time [count > 0]\n");
+ return;
+ }
+
+ if (!_e_info_client_eldbus_message_with_args("key_elapsed_time", NULL, "i", count))
+ printf("_e_info_client_eldbus_message_with_args error");
+ }
+ else
+ {
+ printf("Error Check Args: enlightenment_info -key_elapsed_time [count > 0]\n");
+ return;
+ }
+
+ return;
+}
+
static void
_e_info_client_proc_kvm_transparent_set(int argc, char **argv)
{
"Set input device's subtype(subclas)",
_e_info_client_proc_input_subtype_set
},
+ {
+ "key_elapsed_time", /* Option */
+ "NULL",/* Params */
+ "Print key events elapsed time (default path:/tmp/elapsed_time.txt)", /* Description */
+ _e_info_client_proc_key_elapsed_time /* func */
+ },
};
static Eina_List *list_tracelogs = NULL;
return reply;
}
+static Eldbus_Message *
+_e_info_server_cb_key_elapsed_time(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+ Eldbus_Message *reply;
+ char *result = NULL;
+ int count = 0;
+
+ if (!eldbus_message_arguments_get(msg, "i", &count))
+ {
+ return eldbus_message_error_new(msg, "Key_elapsed_timeFailed",
+ "input_log: an attempt to set key_elapsed_time from method call message failed");
+ }
+
+ result = e_info_server_input_key_elapsed_time(count);
+ reply = eldbus_message_method_return_new(msg);
+
+ eldbus_message_arguments_append(reply, "s", result);
+
+ return reply;
+}
+
//{ "method_name", arguments_from_client, return_values_to_client, _method_cb, ELDBUS_METHOD_FLAG },
static const Eldbus_Method methods[] = {
{ "get_window_info", NULL, ELDBUS_ARGS({"iiiiisiiia("VALUE_TYPE_FOR_TOPVWINS")", "array of ec"}), _e_info_server_cb_window_info_get, 0 },
{ "kvm_transparent", ELDBUS_ARGS({"i", "set kvm service window to transparent"}), NULL, _e_info_server_cb_kvm_transparent_set, 0 },
{ "log_control", ELDBUS_ARGS({"s","log type" }, {"i", "enable"}), NULL, _e_info_server_cb_log_control, 0},
{ VIDEO_SHELL_BORDER_ENABLED_SET_METHOD_NAME, ELDBUS_ARGS({"b", "enable border of video viewport"}), NULL, _e_info_server_cb_video_shell_border_enabled_set, 0},
+ { "key_elapsed_time", ELDBUS_ARGS({"i", "key elapsed time"}), ELDBUS_ARGS({"s", "result message"}), _e_info_server_cb_key_elapsed_time, 0},
{ NULL, NULL, NULL, NULL, 0 }
};
#include "e_input_intern.h"
#include "e_comp_wl_input_intern.h"
#include "e_utils_intern.h"
+#include "e_input_backend_intern.h"
# include <fcntl.h>
#include <linux/uinput.h>
return "Input proper value [1: on][0: off]";
}
+
+EINTERN char *
+e_info_server_input_key_elapsed_time(int count)
+{
+ if (count <= 0) return "count is not valid";
+
+ e_input_backend_key_elapsed_time_print(count);
+
+ return E_INFO_INPUT_RESULT_NONE;
+}
\ No newline at end of file
#define INPUT_ARG_NAME "input"
EINTERN char *e_info_server_input_log_enable_set(int state);
+EINTERN char *e_info_server_input_key_elapsed_time(int count);
#endif
static E_Input_Backend *g_input_backend = NULL;
static E_Input_Event_Source *g_input_event_source = NULL;
static GList *_key_event_list = NULL;
+static GList *_elapsed_time_list = NULL;
+static int _print_count = 0;
GSourceFuncs input_event_funcs = {
.prepare = input_thread_prepare,
return EINA_TRUE;
}
+static double
+_e_input_stddev_get(double avg)
+{
+ double sum = 0;
+ GList *list = g_list_first(_elapsed_time_list);
+ while (list)
+ {
+ unsigned int elapsed_time = (unsigned int)list->data;
+ sum += (elapsed_time - avg) * (elapsed_time - avg);
+ list = list->next;
+ }
+
+ return sqrt(sum / _print_count);
+}
+
+static void
+_e_input_key_elapsed_time_print()
+{
+ char file_path[128] = {'\0', };
+ FILE *fp = NULL;
+ int min = G_MAXINT;
+ int max = 0;
+ double sum = 0;
+ double avg = 0;
+ double std = 0;
+
+ snprintf(file_path, sizeof(file_path), "/tmp/elapsed_time.txt");
+ if (!e_util_file_realpath_check(file_path, EINA_TRUE))
+ WRN("File is already exist");
+
+ fp = fopen(file_path, "w");
+ if (fp)
+ {
+ fprintf(fp, "count=%d\n", _print_count);
+ GList *elapsed_time_list = g_list_first(_elapsed_time_list);
+ while (elapsed_time_list)
+ {
+ unsigned int elapsed_time = (unsigned int)elapsed_time_list->data;
+ if (min > elapsed_time) min = elapsed_time;
+ if (max < elapsed_time) max = elapsed_time;
+
+ sum += elapsed_time;
+ elapsed_time_list = elapsed_time_list->next;
+ fprintf(fp, "%u\n", elapsed_time);
+ }
+
+ avg = sum / _print_count;
+ std = _e_input_stddev_get(avg);
+
+ fprintf(fp, "min=%d\n", min);
+ fprintf(fp, "max=%d\n", max);
+ fprintf(fp, "avg=%.2f\n", avg);
+ fprintf(fp, "std=%.2f\n", std);
+
+ fclose(fp);
+ fp = NULL;
+ }
+ else
+ ERR("Failed to create /tmp/elapsed_time.txt");
+
+ _print_count = 0;
+ g_list_free(_elapsed_time_list);
+ _elapsed_time_list = NULL;
+}
+
static void
_e_input_delayed_key_events_print()
{
Ecore_Event_Key *key = (Ecore_Event_Key *)key_list->data;
if (!key) continue;
+ if (_print_count > 0)
+ {
+ _elapsed_time_list = g_list_append(_elapsed_time_list, (void *)(time - key->timestamp));
+ if (_print_count == g_list_length(_elapsed_time_list))
+ _e_input_key_elapsed_time_print();
+ }
+
if (e_config->key_input_time_limit <= (time - key->timestamp))
ERR("Delayed key event : keyname(%s), keycode(%u), timestamp(%u), elapsed_time(%u ms)", key->keyname, key->keycode, key->timestamp, time - key->timestamp);
break;
}
}
+
+static void
+_e_input_thread_cb_print_count_set(void *data)
+{
+ int count;
+ EINA_SAFETY_ON_NULL_RETURN(data);
+
+ count = *(int *)data;
+ _print_count = count;
+
+ if (_elapsed_time_list)
+ {
+ g_list_free(_elapsed_time_list);
+ _elapsed_time_list = NULL;
+ }
+}
+
+EINTERN void
+e_input_backend_key_elapsed_time_print(int count)
+{
+ e_input_backend_thread_safe_call(_e_input_thread_cb_print_count_set, &count, sizeof(int));
+}
\ No newline at end of file
EINTERN Eina_Bool e_input_backend_libinput_context_create(E_Input_Backend *input);
EINTERN void e_input_backend_log_level_set(E_Input_Backend *input, unsigned int level);
+EINTERN void e_input_backend_key_elapsed_time_print(int count);
#endif