tcc -bench: show text/data/bss binary output sizes

This commit is contained in:
grischka 2020-09-25 18:03:23 +02:00
parent ae1796fc34
commit cdc3df949b
3 changed files with 9 additions and 0 deletions

View File

@ -2115,6 +2115,8 @@ PUB_FUNC void tcc_print_stats(TCCState *s1, unsigned total_time)
(double)total_time/1000,
(unsigned)total_lines*1000/total_time,
(double)total_bytes/1000/total_time);
fprintf(stderr, "* text %d, data %d, bss %d bytes\n",
s1->total_output[0], s1->total_output[1], s1->total_output[2]);
#ifdef MEM_DEBUG
fprintf(stderr, "* %d bytes memory used\n", mem_max_size);
#endif

1
tcc.h
View File

@ -918,6 +918,7 @@ struct TCCState {
int total_idents;
int total_lines;
int total_bytes;
int total_output[3];
/* option -dnum (for general development purposes) */
int g_debug;

View File

@ -202,6 +202,12 @@ ST_FUNC void tccelf_end_file(TCCState *s1)
}
}
tcc_free(tr);
/* record text/data/bss output for -bench info */
for (i = 0; i < 3; ++i) {
s = s1->sections[i + 1];
s1->total_output[i] += s->data_offset - s->sh_offset;
}
}
ST_FUNC Section *new_section(TCCState *s1, const char *name, int sh_type, int sh_flags)