From 74a3f4673d9e6aba785a99d9d740848b4a08620e Mon Sep 17 00:00:00 2001 From: Karl Waclawek Date: Fri, 7 Apr 2006 20:25:43 +0000 Subject: [PATCH] Modified code to use XML_ParserReset() instead of creating a new parser instance on each iteration of the main loop. --- expat/tests/benchmark/benchmark.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/expat/tests/benchmark/benchmark.c b/expat/tests/benchmark/benchmark.c index 86266a00..30a5284f 100644 --- a/expat/tests/benchmark/benchmark.c +++ b/expat/tests/benchmark/benchmark.c @@ -72,15 +72,16 @@ int main (int argc, char *argv[]) fileSize = fread (XMLBuf, sizeof (char), fileAttr.st_size, fd); fclose (fd); + if (ns) + parser = XML_ParserCreateNS(NULL, '!'); + else + parser = XML_ParserCreate(NULL); + i = 0; XMLBufEnd = XMLBuf + fileSize; while (i < nrOfLoops) { XMLBufPtr = XMLBuf; isFinal = 0; - if (ns) - parser = XML_ParserCreateNS(NULL, '!'); - else - parser = XML_ParserCreate(NULL); tstart = clock(); do { int parseBufferSize = XMLBufEnd - XMLBufPtr; @@ -102,10 +103,11 @@ int main (int argc, char *argv[]) } while (!isFinal); tend = clock(); cpuTime += ((double) (tend - tstart)) / CLOCKS_PER_SEC; - XML_ParserFree (parser); + XML_ParserReset(parser, NULL); i++; } + XML_ParserFree (parser); free (XMLBuf); printf ("%d loops, with buffer size %d. Average time per loop: %f\n",