From cf92f7aacbc9e3c828e6a1b68eed6a87d0cf88bd Mon Sep 17 00:00:00 2001 From: seyko Date: Tue, 12 May 2015 22:02:51 +0300 Subject: [PATCH] some -bench fixes print stats to stderr, not to stdout --- libtcc.c | 2 +- tcc.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libtcc.c b/libtcc.c index 1266bafd..fb78c373 100644 --- a/libtcc.c +++ b/libtcc.c @@ -2282,7 +2282,7 @@ PUB_FUNC void tcc_print_stats(TCCState *s, int64_t total_time) tt = 0.001; if (total_bytes < 1) total_bytes = 1; - printf("%d idents, %d lines, %d bytes, %0.3f s, %d lines/s, %0.1f MB/s\n", + fprintf(stderr, "%d idents, %d lines, %d bytes, %0.3f s, %d lines/s, %0.1f MB/s\n", tok_ident - TOK_IDENT, total_lines, total_bytes, tt, (int)(total_lines / tt), total_bytes / tt / 1000000.0); diff --git a/tcc.c b/tcc.c index 6e94f458..ac820ce4 100644 --- a/tcc.c +++ b/tcc.c @@ -245,12 +245,16 @@ static int64_t getclock_us(void) int main(int argc, char **argv) { TCCState *s; - int ret, optind, i, bench; + int ret, optind, i; int64_t start_time = 0; s = tcc_new(); optind = tcc_parse_args(s, argc - 1, argv + 1); + + if (s->do_bench) + start_time = getclock_us(); + tcc_set_environment(s); if (optind == 0) { @@ -296,10 +300,6 @@ int main(int argc, char **argv) } } - bench = s->do_bench; - if (bench) - start_time = getclock_us(); - tcc_set_output_type(s, s->output_type); /* compile or add each files or library */ @@ -339,9 +339,6 @@ int main(int argc, char **argv) } if (0 == ret) { - if (bench) - tcc_print_stats(s, getclock_us() - start_time); - if (s->output_type == TCC_OUTPUT_MEMORY) { #ifdef TCC_IS_NATIVE ret = tcc_run(s, argc - 1 - optind, argv + 1 + optind); @@ -359,6 +356,9 @@ int main(int argc, char **argv) } } + if (s->do_bench) + tcc_print_stats(s, getclock_us() - start_time); + tcc_delete(s); return ret; }