[Expat-checkins] expat/tests/benchmark benchmark.c,1.3,1.4

Karl Waclawek kwaclaw at users.sourceforge.net
Fri Apr 7 22:25:46 CEST 2006


Update of /cvsroot/expat/expat/tests/benchmark
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6233

Modified Files:
	benchmark.c 
Log Message:
Modified code to use XML_ParserReset() instead of creating a new
parser instance on each iteration of the main loop.

Index: benchmark.c
===================================================================
RCS file: /cvsroot/expat/expat/tests/benchmark/benchmark.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- benchmark.c	1 Jan 2006 21:17:41 -0000	1.3
+++ benchmark.c	7 Apr 2006 20:25:43 -0000	1.4
@@ -72,15 +72,16 @@
   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 @@
     } 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", 



More information about the Expat-checkins mailing list