improve command search routine in interpeter, report command execution velocity
This commit is contained in:
parent
e0585f2dac
commit
f9860f5370
@ -49,18 +49,17 @@ TALER_TESTING_interpreter_lookup_command
|
|||||||
(struct TALER_TESTING_Interpreter *is,
|
(struct TALER_TESTING_Interpreter *is,
|
||||||
const char *label)
|
const char *label)
|
||||||
{
|
{
|
||||||
const struct TALER_TESTING_Command *cmd;
|
|
||||||
|
|
||||||
if (NULL == label)
|
if (NULL == label)
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||||
"Attempt to lookup command for empty label\n");
|
"Attempt to lookup command for empty label\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
for (unsigned int i=0;
|
/* Search backwards as we most likely reference recent commands */
|
||||||
NULL != (cmd = &is->commands[i])->label;
|
for (int i=is->ip; 0 >= i; i--)
|
||||||
i++)
|
|
||||||
{
|
{
|
||||||
|
const struct TALER_TESTING_Command *cmd = &is->commands[i];
|
||||||
|
|
||||||
/* Give precedence to top-level commands. */
|
/* Give precedence to top-level commands. */
|
||||||
if ( (NULL != cmd->label) &&
|
if ( (NULL != cmd->label) &&
|
||||||
(0 == strcmp (cmd->label,
|
(0 == strcmp (cmd->label,
|
||||||
@ -72,10 +71,10 @@ TALER_TESTING_interpreter_lookup_command
|
|||||||
#define BATCH_INDEX 1
|
#define BATCH_INDEX 1
|
||||||
struct TALER_TESTING_Command *batch;
|
struct TALER_TESTING_Command *batch;
|
||||||
|
|
||||||
GNUNET_assert
|
GNUNET_assert (GNUNET_OK ==
|
||||||
(GNUNET_OK == TALER_TESTING_get_trait_cmd
|
TALER_TESTING_get_trait_cmd (cmd,
|
||||||
(cmd, BATCH_INDEX, &batch));
|
BATCH_INDEX,
|
||||||
|
&batch));
|
||||||
for (unsigned int i=0;
|
for (unsigned int i=0;
|
||||||
NULL != (cmd = &batch[i])->label;
|
NULL != (cmd = &batch[i])->label;
|
||||||
i++)
|
i++)
|
||||||
@ -169,11 +168,12 @@ interpreter_run (void *cls);
|
|||||||
void
|
void
|
||||||
TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is)
|
TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is)
|
||||||
{
|
{
|
||||||
|
static unsigned long long ipc;
|
||||||
|
static struct GNUNET_TIME_Absolute last_report;
|
||||||
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
|
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
|
||||||
|
|
||||||
if (GNUNET_SYSERR == is->result)
|
if (GNUNET_SYSERR == is->result)
|
||||||
return; /* ignore, we already failed! */
|
return; /* ignore, we already failed! */
|
||||||
|
|
||||||
if (GNUNET_YES == cmd->meta)
|
if (GNUNET_YES == cmd->meta)
|
||||||
{
|
{
|
||||||
#define CURRENT_BATCH_SUBCMD_INDEX 0
|
#define CURRENT_BATCH_SUBCMD_INDEX 0
|
||||||
@ -187,8 +187,18 @@ TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
is->ip++;
|
is->ip++;
|
||||||
|
if (0 == (ipc % 1000))
|
||||||
is->task = GNUNET_SCHEDULER_add_now (&interpreter_run, is);
|
{
|
||||||
|
if (0 != ipc)
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
|
||||||
|
"Interpreter executed 1000 instructions in %s\n",
|
||||||
|
GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (last_report),
|
||||||
|
GNUNET_YES));
|
||||||
|
last_report = GNUNET_TIME_absolute_get ();
|
||||||
|
}
|
||||||
|
ipc++;
|
||||||
|
is->task = GNUNET_SCHEDULER_add_now (&interpreter_run,
|
||||||
|
is);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user