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
22822282 tt = 0.001;
22832283 if (total_bytes < 1)
22842284 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",
22862286 tok_ident - TOK_IDENT, total_lines, total_bytes,
22872287 tt, (int)(total_lines / tt),
22882288 total_bytes / tt / 1000000.0);
tcc.c+8−8
@@ -245,12 +245,16 @@ static int64_t getclock_us(void) · 244 unmodified lines
245245 int main(int argc, char **argv)
246246 {
247247 TCCState *s;
248− int ret, optind, i, bench;
248+ int ret, optind, i;
249249 int64_t start_time = 0;
250250
251251 s = tcc_new();
252252
253253 optind = tcc_parse_args(s, argc - 1, argv + 1);
254+
255+ if (s->do_bench)
256+ start_time = getclock_us();
257+
254258 tcc_set_environment(s);
255259
256260 if (optind == 0) {
@@ -296,10 +300,6 @@ int main(int argc, char **argv) · 39 unmodified lines
296300 }
297301 }
298302
299− bench = s->do_bench;
300− if (bench)
301− start_time = getclock_us();
302−
303303 tcc_set_output_type(s, s->output_type);
304304
305305 /* compile or add each files or library */
@@ -339,9 +339,6 @@ int main(int argc, char **argv) · 33 unmodified lines
339339 }
340340
341341 if (0 == ret) {
342− if (bench)
343− tcc_print_stats(s, getclock_us() - start_time);
344−
345342 if (s->output_type == TCC_OUTPUT_MEMORY) {
346343 #ifdef TCC_IS_NATIVE
347344 ret = tcc_run(s, argc - 1 - optind, argv + 1 + optind);
@@ -359,6 +356,9 @@ int main(int argc, char **argv) · 11 unmodified lines
359356 }
360357 }
361358
359+ if (s->do_bench)
360+ tcc_print_stats(s, getclock_us() - start_time);
361+
362362 tcc_delete(s);
363363 return ret;
364364 }

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