Skip to content

Commit

Permalink
Dump execution time even if JIT-ed code calls exit()
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Apr 17, 2024
1 parent 81ccde4 commit a18a185
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion ir_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,19 @@ static double ir_time(void)
return (double)((((uint64_t)filetime.dwHighDateTime << 32) | (uint64_t)filetime.dwLowDateTime)/10) /
1000000.0;
}

#endif

static double ir_atexit_start = 0.0;

static void ir_atexit(void)
{
if (ir_atexit_start) {
double t = ir_time();
fprintf(stderr, "\nexecution time = %0.6f\n", t - ir_atexit_start);
ir_atexit_start = 0.0;
}
}

static void help(const char *cmd)
{
printf(
Expand Down Expand Up @@ -1428,6 +1438,11 @@ int main(int argc, char **argv)
char **jit_argv;
int (*func)(int, char**) = loader.main;

if (dump_time) {
ir_atexit_start = start;
atexit(ir_atexit);
}

if (run_args && argc > run_args) {
jit_argc = argc - run_args + 1;
}
Expand All @@ -1441,6 +1456,7 @@ int main(int argc, char **argv)
if (dump_time) {
double t = ir_time();
fprintf(stderr, "\nexecution time = %0.6f\n", t - start);
ir_atexit_start = 0.0;
}

#ifndef _WIN32
Expand Down

0 comments on commit a18a185

Please sign in to comment.