From e4781c7820b3bfbc0ad6a911e43a3e1e6abca7c9 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 30 Mar 2020 03:06:55 +0200 Subject: [PATCH] Show execution time in r2r --- binr/r2r/r2r.c | 11 ++++++++++- binr/r2r/run.c | 3 +-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/binr/r2r/r2r.c b/binr/r2r/r2r.c index 20158d415c..dd1da16415 100644 --- a/binr/r2r/r2r.c +++ b/binr/r2r/r2r.c @@ -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); } diff --git a/binr/r2r/run.c b/binr/r2r/run.c index 1e66eed928..0a4036d239 100644 --- a/binr/r2r/run.c +++ b/binr/r2r/run.c @@ -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; }