History

some -bench fixes

print stats to stderr, not to stdout

seyko committed 11 years ago

Commit cf92f7a1 parent 06e07532 files · +9 −9Browse files

Unified · Split

2 files
  1. libtcc.c +1 −1
  2. tcc.c +8 −8
libtcc.c+1−1
@@ -2282,7 +2282,7 @@ PUB_FUNC void tcc_print_stats(TCCState *s, int64_t total_time) · 2281 unmodified lines
2282 tt = 0.001;2282 tt = 0.001;
2283 if (total_bytes < 1)2283 if (total_bytes < 1)
2284 total_bytes = 1;2284 total_bytes = 1;
2285 printf("%d idents, %d lines, %d bytes, %0.3f s, %d lines/s, %0.1f MB/s\n",2285 fprintf(stderr, "%d idents, %d lines, %d bytes, %0.3f s, %d lines/s, %0.1f MB/s\n",
2286 tok_ident - TOK_IDENT, total_lines, total_bytes,2286 tok_ident - TOK_IDENT, total_lines, total_bytes,
2287 tt, (int)(total_lines / tt),2287 tt, (int)(total_lines / tt),
2288 total_bytes / tt / 1000000.0);2288 total_bytes / tt / 1000000.0);
tcc.c+8−8
@@ -245,12 +245,16 @@ static int64_t getclock_us(void) · 244 unmodified lines
245int main(int argc, char **argv)245int main(int argc, char **argv)
246{246{
247 TCCState *s;247 TCCState *s;
248 int ret, optind, i, bench;248 int ret, optind, i;
249 int64_t start_time = 0;249 int64_t start_time = 0;
250 250
251 s = tcc_new();251 s = tcc_new();
252 252
253 optind = tcc_parse_args(s, argc - 1, argv + 1);253 optind = tcc_parse_args(s, argc - 1, argv + 1);
254
255 if (s->do_bench)
256 start_time = getclock_us();
257
254 tcc_set_environment(s);258 tcc_set_environment(s);
255 259
256 if (optind == 0) {260 if (optind == 0) {
@@ -296,10 +300,6 @@ int main(int argc, char **argv) · 39 unmodified lines
296 }300 }
297 }301 }
298 302
299 bench = s->do_bench;
300 if (bench)
301 start_time = getclock_us();
302
303 tcc_set_output_type(s, s->output_type);303 tcc_set_output_type(s, s->output_type);
304 304
305 /* compile or add each files or library */305 /* compile or add each files or library */
@@ -339,9 +339,6 @@ int main(int argc, char **argv) · 33 unmodified lines
339 }339 }
340 340
341 if (0 == ret) {341 if (0 == ret) {
342 if (bench)
343 tcc_print_stats(s, getclock_us() - start_time);
344
345 if (s->output_type == TCC_OUTPUT_MEMORY) {342 if (s->output_type == TCC_OUTPUT_MEMORY) {
346#ifdef TCC_IS_NATIVE343#ifdef TCC_IS_NATIVE
347 ret = tcc_run(s, argc - 1 - optind, argv + 1 + optind);344 ret = tcc_run(s, argc - 1 - optind, argv + 1 + optind);
@@ -359,6 +356,9 @@ int main(int argc, char **argv) · 11 unmodified lines
359 }356 }
360 }357 }
361 358
359 if (s->do_bench)
360 tcc_print_stats(s, getclock_us() - start_time);
361
362 tcc_delete(s);362 tcc_delete(s);
363 return ret;363 return ret;
364}364}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t