aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseyko <seyko2@gmail.com>2015-05-12 22:02:51 +0300
committerseyko <seyko2@gmail.com>2015-05-12 22:02:51 +0300
commitcf92f7aacbc9e3c828e6a1b68eed6a87d0cf88bd (patch)
treeba6a1ea0a69c57391eab4e40f09947e2ed96c4c0
parent06e0753fce99d4b845c054ce343f49149522ff2c (diff)
downloadtinycc-cf92f7aacbc9e3c828e6a1b68eed6a87d0cf88bd.tar.gz
tinycc-cf92f7aacbc9e3c828e6a1b68eed6a87d0cf88bd.tar.bz2
some -bench fixes
print stats to stderr, not to stdout
-rw-r--r--libtcc.c2
-rw-r--r--tcc.c16
2 files changed, 9 insertions, 9 deletions
diff --git a/libtcc.c b/libtcc.c
index 1266baf..fb78c37 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 6e94f45..ac820ce 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;
}