some -bench fixes

print stats to stderr, not to stdout
This commit is contained in:
seyko 2015-05-12 22:02:51 +03:00
parent 06e0753fce
commit cf92f7aacb
2 changed files with 9 additions and 9 deletions

View File

@ -2282,7 +2282,7 @@ PUB_FUNC void tcc_print_stats(TCCState *s, int64_t total_time)
tt = 0.001; tt = 0.001;
if (total_bytes < 1) if (total_bytes < 1)
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, tok_ident - TOK_IDENT, total_lines, total_bytes,
tt, (int)(total_lines / tt), tt, (int)(total_lines / tt),
total_bytes / tt / 1000000.0); total_bytes / tt / 1000000.0);

16
tcc.c
View File

@ -245,12 +245,16 @@ static int64_t getclock_us(void)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
TCCState *s; TCCState *s;
int ret, optind, i, bench; int ret, optind, i;
int64_t start_time = 0; int64_t start_time = 0;
s = tcc_new(); s = tcc_new();
optind = tcc_parse_args(s, argc - 1, argv + 1); optind = tcc_parse_args(s, argc - 1, argv + 1);
if (s->do_bench)
start_time = getclock_us();
tcc_set_environment(s); tcc_set_environment(s);
if (optind == 0) { 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); tcc_set_output_type(s, s->output_type);
/* compile or add each files or library */ /* compile or add each files or library */
@ -339,9 +339,6 @@ int main(int argc, char **argv)
} }
if (0 == ret) { if (0 == ret) {
if (bench)
tcc_print_stats(s, getclock_us() - start_time);
if (s->output_type == TCC_OUTPUT_MEMORY) { if (s->output_type == TCC_OUTPUT_MEMORY) {
#ifdef TCC_IS_NATIVE #ifdef TCC_IS_NATIVE
ret = tcc_run(s, argc - 1 - optind, argv + 1 + optind); 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); tcc_delete(s);
return ret; return ret;
} }