diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2014-11-13 11:00:04 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2014-11-13 11:00:15 -0800 |
commit | 7861d82c6fcfb3f813e642c0f59318eb4f9f5332 (patch) | |
tree | 116269e4b4341222530c7acbde6b1b54d3138f4c /src/main.c | |
parent | 3c9bdf645958a1c5b71cc9b96a5b711cca14224f (diff) |
Added bench.h and inserted timing macros in main.
`make TIMER=1` to build with timings.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -3,6 +3,7 @@ #include <string.h> #include <errno.h> #include "cmark.h" +#include "bench.h" void print_usage() { @@ -25,6 +26,19 @@ static void print_document(node_block *document, bool ast) } } +void parse_and_render(node_block *document, FILE *fp, bool ast) +{ + start_timer(); + document = cmark_parse_file(fp); + end_timer("cmark_parse_file"); + start_timer(); + print_document(document, ast); + end_timer("print_document"); + start_timer(); + cmark_free_blocks(document); + end_timer("free_blocks"); +} + int main(int argc, char *argv[]) { int i, numfps = 0; @@ -52,9 +66,7 @@ int main(int argc, char *argv[]) } if (numfps == 0) { - document = cmark_parse_file(stdin); - print_document(document, ast); - cmark_free_blocks(document); + parse_and_render(document, stdin, ast); } else { for (i = 0; i < numfps; i++) { FILE *fp = fopen(argv[files[i]], "r"); @@ -65,9 +77,7 @@ int main(int argc, char *argv[]) exit(1); } - document = cmark_parse_file(fp); - print_document(document, ast); - cmark_free_blocks(document); + parse_and_render(document, fp, ast); fclose(fp); } } |