Show execution time in r2r

This commit is contained in:
pancake 2020-03-30 03:06:55 +02:00 committed by radare
parent 1bf0fed6cc
commit e4781c7820
2 changed files with 11 additions and 3 deletions

View File

@ -100,6 +100,7 @@ int main(int argc, char **argv) {
}
atexit (r2r_subprocess_fini);
ut64 time_start = r_sys_now ();
R2RState state = {{0}};
state.run_config.r2_cmd = radare2_cmd ? radare2_cmd : RADARE2_CMD_DEFAULT;
state.run_config.rasm2_cmd = rasm2_cmd ? rasm2_cmd : RASM2_CMD_DEFAULT;
@ -203,6 +204,14 @@ int main(int argc, char **argv) {
r2r_test_database_free (state.db);
r_th_lock_free (state.lock);
r_th_cond_free (state.cond);
ut64 seconds = (r_sys_now () - time_start) / 1000000;
printf ("Finished in");
if (seconds > 60) {
ut64 minutes = seconds / 60;
printf (" %"PFMT64d" minutes and", seconds / 60);
seconds -= (minutes * 60);
}
printf (" %"PFMT64d" seconds.\n", seconds % 60);
beach:
free (radare2_cmd);
free (rasm2_cmd);
@ -382,7 +391,7 @@ static void print_state(R2RState *state, ut64 prev_completed) {
w++;
}
printf (" ");
printf ("OK %8"PFMT64u" BR %8"PFMT64u" XX %8"PFMT64u" FX %8"PFMT64u,
printf ("%8"PFMT64u" OK %8"PFMT64u" BR %8"PFMT64u" XX %8"PFMT64u" FX",
state->ok_count, state->br_count, state->xx_count, state->fx_count);
fflush (stdout);
}

View File

@ -156,7 +156,6 @@ R_API R2RSubprocess *r2r_subprocess_start(
memcpy (argv + 1, args, sizeof (char *) * args_size);
}
// done by calloc: argv[args_size + 1] = NULL;
R2RSubprocess *proc = R_NEW0 (R2RSubprocess);
if (!proc) {
goto error;
@ -170,7 +169,7 @@ R_API R2RSubprocess *r2r_subprocess_start(
perror ("pipe");
goto error;
}
if (fcntl(proc->killpipe[1], F_SETFL, O_NONBLOCK) < 0) {
if (fcntl (proc->killpipe[1], F_SETFL, O_NONBLOCK) < 0) {
perror ("fcntl");
goto error;
}