Modified code to use XML_ParserReset() instead of creating a new

parser instance on each iteration of the main loop.
This commit is contained in:
Karl Waclawek 2006-04-07 20:25:43 +00:00
parent 8617df5d5e
commit 74a3f4673d

View File

@ -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",