Inspector: add optimize option

In most scenarios, a lot of time is useless and taken by the human
inaction or slowness.

This optimizer tries to increase the scenario speed by removing this
wasted time. Stabilization is required before shots.

Note that animated tests such as label_slide cannot be optimized well.
The reason is that a stabilization is done at the beginning of the test,
resulting in an endless loop (slide always moving).
This commit is contained in:
Daniel Zaoui 2018-10-29 10:04:24 +02:00
parent 3d02d1c50e
commit b95961ba0c
1 changed files with 54 additions and 1 deletions

View File

@ -1112,6 +1112,7 @@ static const Ecore_Getopt optdesc = {
ECORE_GETOPT_STORE_TRUE('C', "compare", "Compare given files (images files or objects eet files)."),
ECORE_GETOPT_STORE_TRUE(0, "show-only-diffs", "Show only differences during comparison."),
ECORE_GETOPT_STORE_TRUE(0, "stabilize", "Stabilize after the given shot number in --shot."),
ECORE_GETOPT_STORE_TRUE(0, "optimize", "Optimize the given recording into the given output."),
ECORE_GETOPT_STORE_STR('o', "output", "Output."),
ECORE_GETOPT_STORE_USHORT('s', "shot", "Select a specific shot (1 = 1st shot...)."),
@ -1134,6 +1135,7 @@ main(int argc, char *argv[])
Eina_Bool write_file = EINA_FALSE;
Eina_Bool want_quit, clean = EINA_FALSE, list_get = EINA_FALSE, compare_files = EINA_FALSE;
Eina_Bool stabilize = EINA_FALSE, show_only_diffs = EINA_FALSE, gui_needed = EINA_TRUE;
Eina_Bool optimize = EINA_FALSE;
Ecore_Getopt_Value values[] = {
ECORE_GETOPT_VALUE_USHORT(delay),
@ -1142,6 +1144,7 @@ main(int argc, char *argv[])
ECORE_GETOPT_VALUE_BOOL(compare_files),
ECORE_GETOPT_VALUE_BOOL(show_only_diffs),
ECORE_GETOPT_VALUE_BOOL(stabilize),
ECORE_GETOPT_VALUE_BOOL(optimize),
ECORE_GETOPT_VALUE_STR(output),
ECORE_GETOPT_VALUE_USHORT(shot),
@ -1207,7 +1210,7 @@ main(int argc, char *argv[])
}
_show_only_diffs = show_only_diffs;
if (clean || delay || list_get || stabilize)
if (clean || delay || list_get || stabilize || optimize)
{
const char *src_file = NULL;
src_file = argv[args];
@ -1316,6 +1319,56 @@ main(int argc, char *argv[])
}
}
if (optimize)
{
Eina_List *itr, *itr2;
Exactness_Action_Type last_action_type = EXACTNESS_ACTION_STABILIZE;
Eina_Bool no_remove = EINA_FALSE;
Exactness_Action *act = calloc(1, sizeof(*act));
act->type = EXACTNESS_ACTION_STABILIZE;
act->delay_ms = 200;
unit->actions = eina_list_prepend(unit->actions, act);
EINA_LIST_FOREACH_SAFE(unit->actions, itr, itr2, act)
{
switch (act->type)
{
case EXACTNESS_ACTION_MULTI_MOVE:
{
Exactness_Action *next_act = eina_list_data_get(itr2);
/* Don't remove the last MOVE before DOWN */
if (next_act && next_act->type == EXACTNESS_ACTION_MULTI_DOWN) break;
/* Don't remove MOVE between DOWN and UP */
if (no_remove) break;
unit->actions = eina_list_remove(unit->actions, act);
break;
}
case EXACTNESS_ACTION_MULTI_DOWN: case EXACTNESS_ACTION_MULTI_UP:
{
no_remove = (act->type == EXACTNESS_ACTION_MULTI_DOWN);
break;
}
case EXACTNESS_ACTION_TAKE_SHOT:
{
if (last_action_type != EXACTNESS_ACTION_STABILIZE)
{
Exactness_Action *act2 = calloc(1, sizeof(*act2));
act2->type = EXACTNESS_ACTION_STABILIZE;
unit->actions = eina_list_prepend_relative(
unit->actions, act2, act);
}
act->delay_ms = 0;
break;
}
default:
{
break;
}
}
last_action_type = act->type;
}
write_file = EINA_TRUE;
}
if (list_get)
{
Exactness_Action *act;