mirror of
https://github.com/frida/tinycc
synced 2024-11-24 16:49:44 +03:00
some -bench fixes
print stats to stderr, not to stdout
This commit is contained in:
parent
06e0753fce
commit
cf92f7aacb
2
libtcc.c
2
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);
|
||||
|
16
tcc.c
16
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user