diff options
author | ragge <ragge> | 2008-11-24 07:13:09 +0000 |
---|---|---|
committer | ragge <ragge> | 2008-11-24 07:13:09 +0000 |
commit | 6f88fdadf2c9d1a223ca679ba2624d42ea1755b7 (patch) | |
tree | 6687a0256364123a24d575572be9dd8c199087d3 | |
parent | 98ba884fe9f21d8e33c499bda83b5d22252d2b15 (diff) |
Add compile-time option to print out time used in execution.
Only used during testing and debugging.
-rw-r--r-- | cpp.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -186,6 +186,12 @@ main(int argc, char **argv) struct symtab *nl; register int ch; +#ifdef TIMING + struct timeval t1, t2; + + (void)gettimeofday(&t1, NULL); +#endif + while ((ch = getopt(argc, argv, "CD:I:MPS:U:d:i:tvV?")) != -1) switch (ch) { case 'C': /* Do not discard comments */ @@ -315,6 +321,17 @@ main(int argc, char **argv) flbuf(); close(ofd); +#ifdef TIMING + (void)gettimeofday(&t2, NULL); + t2.tv_sec -= t1.tv_sec; + t2.tv_usec -= t1.tv_usec; + if (t2.tv_usec < 0) { + t2.tv_usec += 1000000; + t2.tv_sec -= 1; + } + fprintf(stderr, "cpp total time: %ld s %ld us\n", + t2.tv_sec, t2.tv_usec); +#endif return 0; } |